Skip to content

Commit

Permalink
fixes issue in prepare script
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescodesthings committed May 6, 2021
1 parent 923d441 commit f1bb613
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/scripts/prepare.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
const { exec } = require('child_process');
const semver = require('semver');

function getTnsVersion() {

try {
return semver.major(stdout);
} catch(error) {
try {
const regex = /(^\d\.\d\.\d$)/gm;
const match = regex.exec(stdout);

if (match && match[0]) {
return semver.major(match[0]);
}
} catch(error) {
// noop
}
}

console.warn('Could not get Nativescript version from nativescript cli. Assuming version 7+');
return 7;
}

exec('tns --version', (err, stdout, stderr) => {
if (err) {
// node couldn't execute the command
console.log(`tns --version err: ${err}`);
return;
}

const tnsVersion = semver.major(stdout);
const tnsVersion = getTnsVersion();

// execute 'tns plugin build' for {N} version > 4. This command builds .aar in platforms/android folder.
if (tnsVersion >= 4) {
console.log(`executing 'tns plugin build'`);
exec('tns plugin build');
}
});
});

0 comments on commit f1bb613

Please sign in to comment.