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

Commit 3116e5d

Browse files
fix(ns-bundle): support for Node.js 9
When you have Node.js 9 installed, CLI prints a warning that support for this version is not verified. Our webpack plugin tries to get the version, but it receives the warning and decides the version is incorrect. So all scripts fail. In order to resolve the issue, get all data send to the stdout of the spawned `tns --version` process and parse it.
1 parent df12dfc commit 3116e5d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Diff for: bin/ns-bundle

+10-5
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ execute(options);
5353

5454
function execute(options) {
5555
const platform = options.platform;
56-
let commands = [
57-
() => runTns("prepare", platform)
56+
let commands = [
57+
() => runTns("prepare", platform)
5858
];
5959

6060
if (options.bundle) {
@@ -70,7 +70,7 @@ function execute(options) {
7070
if (shouldSnapshot(platform, options.env)) {
7171
commands.push(() => installSnapshotArtefacts());
7272
}
73-
73+
7474
// If "build-app" or "start-app" is specified,
7575
// the respective command should be run last.
7676
if (options.command) {
@@ -123,15 +123,20 @@ function gradlewClean() {
123123
function getTnsVersion() {
124124
return new Promise((resolve, reject) => {
125125
const childProcess = spawn("tns", ["--version"], { shell: true });
126-
127-
childProcess.stdout.on("data", version => resolve(version.toString()));
126+
let stdoutData = "";
127+
childProcess.stdout.on("data", data => stdoutData += data);
128128

129129
childProcess.on("close", code => {
130130
if (code) {
131131
reject({
132132
code,
133133
message: `child process exited with code ${code}`,
134134
});
135+
} else {
136+
const versionRegex = /^(?:\d+\.){2}\d+.*?$/m;
137+
const matches = stdoutData.toString().match(versionRegex);
138+
const version = matches && matches[0] && matches[0].trim();
139+
resolve(version);
135140
}
136141
});
137142
});

0 commit comments

Comments
 (0)