Files
playlet-piped/tools/update-manifest-git-hash.js
T
Brahim Hadriche 043a0e5301 [part 1] Feature/ci release (#48)
* Git status check

* Add git hash to manifest
2023-02-10 20:31:25 -05:00

26 lines
788 B
JavaScript

const fs = require('fs');
const shell = require('shelljs');
if (!shell.which('git')) {
shell.echo('Sorry, this script requires git');
shell.exit(1);
}
const gitStatus = shell.exec('git status --porcelain=v1');
if (gitStatus.stdout !== '') {
shell.echo('Found changed files. Aborting.');
shell.exit(1);
}
const gitCommitHash = shell.exec('git rev-parse HEAD').stdout.trim();
["playlet/src/manifest", "playlet-lib/src/manifest"].forEach(function (manifestPath) {
let appManifestContent = fs.readFileSync(manifestPath, { encoding: 'utf8', flag: 'r' });
const gitHashPattern = /git_commit_sha=(\w+)/;
appManifestContent = appManifestContent.replace(gitHashPattern, `git_commit_sha=${gitCommitHash}`);
fs.writeFileSync(manifestPath, appManifestContent);
})