Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: replace stamp bash script with node script (#367)
* build: replace stamp bash script with node script * build: move stamp script to tools dir * build: fix npm stamp script
- Loading branch information
1 parent
d693942
commit e79d468
Showing
5 changed files
with
188 additions
and
28 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const simpleGit = require('simple-git'); | ||
const replace = require('replace-in-file'); | ||
const git = simpleGit(); | ||
|
||
/** Get build number from current git revision */ | ||
const getBuildNumber = () => | ||
Promise.all([ | ||
git.revparse(['--abbrev-ref', 'HEAD']), | ||
git.revparse(['--short', 'HEAD']), | ||
]).then(([b, v]) => `${b}+sha.${v}`); | ||
|
||
/** Replace _BUILD_HASH_ in dist files with the current build number */ | ||
const replaceBuildHash = (buildNumber) => | ||
replace({ | ||
from: /_BUILD_HASH_/g, | ||
to: buildNumber, | ||
files: 'dist/**/**/*.js', | ||
}).then(() => buildNumber); | ||
|
||
// Run script | ||
getBuildNumber() | ||
.then(replaceBuildHash) | ||
.then((buildNumber) => { | ||
console.log(`Build was stamped: ${buildNumber}`); | ||
}) | ||
.catch((e) => { | ||
console.error('Could not stamp this build!', e); | ||
}); |