Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 8af7d77

Browse files
EddyVerbruggeneddyverbruggen
authored andcommitted
#293 Fix postinstall when nativescript is not in the PATH - added to master file (postinstall.js is generated by webpack from installer.js)
1 parent 77d2ea8 commit 8af7d77

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

scripts/installer.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,24 @@ function readConfig() {
3636
}
3737

3838
// workaround for https://github.com/NativeScript/nativescript-cli/issues/2521 (2.5.0 only)
39-
var nativeScriptVersion = require('child_process').execSync('nativescript --version');
40-
var promptSupported = nativeScriptVersion.indexOf("2.5.0") === -1;
39+
var nativeScriptVersion = "";
40+
try {
41+
nativeScriptVersion = __webpack_require__(/*! child_process */ 2).execSync('nativescript --version');
42+
} catch (err) {
43+
// On some environments nativescript is not in the PATH
44+
// Ignore the error
45+
}
46+
47+
var isNativeScriptCLI250 = nativeScriptVersion.indexOf("2.5.0") !== -1;
4148

4249
// note that for CI builds you want a pluginConfigFile, otherwise the build will fail
43-
if (process.argv.indexOf("config") == -1 && fs.existsSync(pluginConfigPath)) {
50+
if (process.argv.indexOf("config") === -1 && fs.existsSync(pluginConfigPath)) {
4451
readConfig();
4552
console.log("Config file exists (" + pluginConfigFile + ")");
4653
askiOSPromptResult(config);
4754
askAndroidPromptResult(config);
4855
promptQuestionsResult(config);
49-
} else if (!promptSupported && process.argv.indexOf("setup") == -1) {
56+
} else if (isNativeScriptCLI250 && process.argv.indexOf("setup") === -1) {
5057
console.log("*******************************************************************");
5158
console.log("*******************************************************************");
5259
console.log("************************** IMPORTANT: *****************************");

0 commit comments

Comments
 (0)