forked from dapriett/nativescript-google-maps-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix/prepare-script' into fix/ns7
Merge this in to ensure we can build easily
- Loading branch information
Showing
1 changed file
with
23 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
}); | ||
}); |