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

fix(ns-bundle): support for Node.js 9 #321

Merged
merged 1 commit into from
Nov 19, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions bin/ns-bundle
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ execute(options);

function execute(options) {
const platform = options.platform;
let commands = [
() => runTns("prepare", platform)
let commands = [
() => runTns("prepare", platform)
];

if (options.bundle) {
Expand All @@ -70,7 +70,7 @@ function execute(options) {
if (shouldSnapshot(platform, options.env)) {
commands.push(() => installSnapshotArtefacts());
}

// If "build-app" or "start-app" is specified,
// the respective command should be run last.
if (options.command) {
Expand Down Expand Up @@ -123,15 +123,20 @@ function gradlewClean() {
function getTnsVersion() {
return new Promise((resolve, reject) => {
const childProcess = spawn("tns", ["--version"], { shell: true });

childProcess.stdout.on("data", version => resolve(version.toString()));
let stdoutData = "";
childProcess.stdout.on("data", data => stdoutData += data);

childProcess.on("close", code => {
if (code) {
reject({
code,
message: `child process exited with code ${code}`,
});
} else {
const versionRegex = /^(?:\d+\.){2}\d+.*?$/m;
const matches = stdoutData.toString().match(versionRegex);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a dependency to 'semver'. We can use it instead if the regex.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here is to get the version from the string. Output of tns --version is:

Support for Node.js 9.0.0 is not verified. This CLI might not install or run properly.

3.3.0

So the regex should find the 3.3.0 version from it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense 👍

const version = matches && matches[0] && matches[0].trim();
resolve(version);
}
});
});
Expand Down