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

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

lib/after-prepare.js

+6-1
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

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

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

26+
function ensureDirectoryExistence(filePath) {
27+
var dir = dirname(filePath);
28+
if (existsSync(dir)) {
29+
return true;
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

+3-12
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
const validateOptions = require("schema-utils");
44

55
const ProjectSnapshotGenerator = 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
const schema = require("./options.json");
1213

1314
const SNAPSHOT_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-
function ensureDirectoryExistence(filePath) {
74-
var dir = dirname(filePath);
75-
if (existsSync(dir)) {
76-
return true;
77-
}
78-
ensureDirectoryExistence(dir);
79-
mkdirSync(dir);
80-
}
81-
8273
NativeScriptSnapshotPlugin.getInternalRequireModules = function (webpackContext) {
8374
const packageJson = getPackageJson(webpackContext);
8475
return (packageJson && packageJson["android"] && packageJson["android"]["requireModules"]) || [];

0 commit comments

Comments
 (0)