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

Commit c2e2011

Browse files
author
Dimitar Tachev
authored
Merge pull request #1117 from NativeScript/tachev/fix-cloud-snapshot
fix: stop looking for local snapshot artefacts when the native prepare is skipped
2 parents 53cac58 + b8da140 commit c2e2011

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
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

+2-1
Original file line numberDiff line numberDiff line change
@@ -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";
@@ -57,6 +58,7 @@ exports.NativeScriptSnapshotPlugin = (function () {
5758
snapshotEntryContent += [...requireModules, ...internalRequireModules]
5859
.map(mod => `require('${mod}')`).join(";");
5960

61+
ensureDirectoryExistence(snapshotEntryPath);
6062
writeFileSync(snapshotEntryPath, snapshotEntryContent, { encoding: "utf8" });
6163

6264
// add the module to the entry points to make sure it's content is evaluated
@@ -68,7 +70,6 @@ exports.NativeScriptSnapshotPlugin = (function () {
6870
// ensure that the runtime is installed only in the snapshotted chunk
6971
webpackConfig.optimization.runtimeChunk = { name: SNAPSHOT_ENTRY_NAME };
7072
}
71-
7273
NativeScriptSnapshotPlugin.getInternalRequireModules = function (webpackContext) {
7374
const packageJson = getPackageJson(webpackContext);
7475
return (packageJson && packageJson["android"] && packageJson["android"]["requireModules"]) || [];

0 commit comments

Comments
 (0)