Skip to content

Commit dd2df8d

Browse files
committed
feat: add before-liveSync hook in order to show an error that this version of runner is not compatible with old CLI
1 parent 39cef6d commit dd2df8d

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Diff for: lib/before-liveSync.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = function ($staticConfig, $errors, hookArgs) {
2+
var majorVersionMatch = ($staticConfig.version || '').match(/^(\d+)\./);
3+
var majorVersion = majorVersionMatch && majorVersionMatch[1] && +majorVersionMatch[1];
4+
if (majorVersion && majorVersion < 6) {
5+
var isUsingBundleWorkflow = hookArgs &&
6+
hookArgs.liveSyncData &&
7+
hookArgs.liveSyncData.bundle;
8+
if (isUsingBundleWorkflow) {
9+
var packageJsonData = require("../package.json");
10+
throw new Error("The current version of " + packageJsonData.name + " (" + packageJsonData.version + ") is not compatible with the used CLI: " + $staticConfig.version + ". Please upgrade your NativeScript CLI version (npm i -g nativescript).");
11+
}
12+
}
13+
};

Diff for: package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@
2929
{
3030
"type": "after-prepare",
3131
"script": "./lib/after-prepare.js",
32-
"inject": "true"
32+
"inject": true
33+
},
34+
{
35+
"type": "before-liveSync",
36+
"script": "lib/before-liveSync.js",
37+
"inject": true
3338
}
3439
]
3540
},

0 commit comments

Comments
 (0)