Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit b8da140

Browse files
committed
fix: stop searching for snapshot artefacts when the snapshot tools are skipped (it's a cloud build, there aren't any snapshot artefacts locally)
1 parent 2a0eaf6 commit b8da140

3 files changed

Lines changed: 22 additions & 14 deletions

File tree

‎lib/after-prepare.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ module.exports = function (hookArgs) {
1212
release: hookArgs.prepareData.release
1313
};
1414

15-
if(env.snapshot&&shouldSnapshot(shouldSnapshotOptions)){
15+
if(env.snapshot&&
16+
shouldSnapshot(shouldSnapshotOptions)&&
17+
(!hookArgs.prepareData||
18+
!hookArgs.prepareData.nativePrepare||
19+
!hookArgs.prepareData.nativePrepare.skipNativePrepare)){
20+
1621
installSnapshotArtefacts(hookArgs.prepareData.projectDir);
1722
}
1823
}

‎lib/utils.js‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
constos=require("os");
2+
const{ dirname }=require("path");
3+
const{ existsSync, mkdirSync }=require("fs");
24
const{ isAndroid }=require("../projectHelpers");
35

46
functionshouldSnapshot(config){
@@ -21,9 +23,19 @@ function warn(message) {
2123
}
2224
}
2325

26+
functionensureDirectoryExistence(filePath){
27+
vardir=dirname(filePath);
28+
if(existsSync(dir)){
29+
returntrue;
30+
}
31+
ensureDirectoryExistence(dir);
32+
mkdirSync(dir);
33+
}
34+
2435
module.exports={
2536
shouldSnapshot,
2637
convertToUnixPath,
2738
isWinOS,
28-
warn
39+
warn,
40+
ensureDirectoryExistence
2941
};

‎plugins/NativeScriptSnapshotPlugin/index.js‎

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const{ relative, resolve, join, dirname}=require("path");
2-
const{ closeSync, openSync, writeFileSync, existsSync, mkdirSync}=require("fs");
1+
const{ relative, resolve, join }=require("path");
2+
const{ closeSync, openSync, writeFileSync }=require("fs");
33
constvalidateOptions=require("schema-utils");
44

55
constProjectSnapshotGenerator=require("../../snapshot/android/project-snapshot-generator");
@@ -8,6 +8,7 @@ const {
88
ANDROID_PROJECT_DIR,
99
ANDROID_APP_PATH,
1010
}=require("../../androidProjectHelpers");
11+
const{ ensureDirectoryExistence }=require("../../lib/utils");
1112
constschema=require("./options.json");
1213

1314
constSNAPSHOT_ENTRY_NAME="snapshot-entry";
@@ -69,16 +70,6 @@ exports.NativeScriptSnapshotPlugin = (function () {
6970
// ensure that the runtime is installed only in the snapshotted chunk
7071
webpackConfig.optimization.runtimeChunk={name: SNAPSHOT_ENTRY_NAME};
7172
}
72-
73-
functionensureDirectoryExistence(filePath){
74-
vardir=dirname(filePath);
75-
if(existsSync(dir)){
76-
returntrue;
77-
}
78-
ensureDirectoryExistence(dir);
79-
mkdirSync(dir);
80-
}
81-
8273
NativeScriptSnapshotPlugin.getInternalRequireModules=function(webpackContext){
8374
constpackageJson=getPackageJson(webpackContext);
8475
return(packageJson&&packageJson["android"]&&packageJson["android"]["requireModules"])||[];

0 commit comments

Comments
 (0)