forked from NativeScript/nativescript-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd-publishConfig.js
33 lines (25 loc) · 898 Bytes
/
add-publishConfig.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env node
var fsModule = require('fs');
//Adds a publishConfig section to the package.json file
// and sets a tag to it
var path = './package.json';
var fileOptions = {encoding: "utf-8"};
var content = fsModule.readFileSync(path, fileOptions);
var tag = process.argv[2];
if (!tag) {
console.log('Please pass the tag name as an argument!');
process.exit(1);
}
var packageDef = JSON.parse(content);
if (!packageDef.publishConfig) {
packageDef.publishConfig = {};
}
packageDef.publishConfig.tag = tag;
if (packageDef.private) {
delete packageDef.private;
}
// adding date and travis build number (2016-07-18-765) to version in order to get unique version for @next build
var package_version = process.argv[3];
packageDef.version += '-' + package_version;
var newContent = JSON.stringify(packageDef, null, ' ');
fsModule.writeFileSync(path, newContent, fileOptions);