Files
playlet-piped/tools/update-manifest-git-hash.js
Brahim Hadriche 112bad5d42 Fix/windows builds (#764)
* Fix windows path issues

* Few script changes to support windows

* Update build scripts

* remove duplicate call

* changelog

* Fix for telnet test runner
2025-10-22 09:38:38 -04:00

31 lines
1.0 KiB
JavaScript

// Description: Updates the git commit hash in the manifest files.
// It will update both Playlet and Playlet-lib manifest files.
// It will abort if there are any changes in the working directory.
const fs = require('fs');
const shell = require('shelljs');
const path = require('path');
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 --short HEAD').stdout.trim();
[path.join("playlet-app", "src", "manifest"), path.join("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);
})