Create appendCommitToVersion.js
This commit is contained in:
parent
89a8ae3480
commit
7c5688b5e5
1 changed files with 23 additions and 0 deletions
23
resources/appendCommitToVersion.js
Normal file
23
resources/appendCommitToVersion.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
if (!process.env['CIRCLECI']) {
|
||||
console.log(`[CIRCLECI SCRIPT] CircleCI not found... Aborting script`)
|
||||
return
|
||||
}
|
||||
|
||||
let fs = require('fs')
|
||||
|
||||
var data = fs.readFileSync('package.json');
|
||||
var package = JSON.parse(data);
|
||||
|
||||
//Six chars of commit sha
|
||||
// https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables
|
||||
let shortCommitSha = String(process.env['CIRCLE_SHA1']).slice(0,5)
|
||||
|
||||
|
||||
package.version = `${package.version}-${shortCommitSha}`
|
||||
|
||||
|
||||
fs.writeFile('package.json', newData, err => {
|
||||
// error checking
|
||||
if(err) throw err;
|
||||
console.log("VERSION CHANGED");
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue