Attach commit as package.json#gitHead in prerelease versions (#47932)

This commit is contained in:
Mateusz Burzyński 2023-03-07 17:35:16 +01:00 committed by GitHub
parent 6dbec02a88
commit 9f8a160d53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
import assert from "assert";
import { execFileSync } from "child_process";
import { readFileSync, writeFileSync } from "fs";
import { normalize, relative } from "path";
import url from "url";
@ -51,6 +52,7 @@ function main() {
// Finally write the changes to disk.
// Modify the package.json structure
packageJsonValue.version = `${majorMinor}.${prereleasePatch}`;
packageJsonValue.gitHead = execFileSync("git", ["rev-parse", "HEAD"], { encoding: "utf8" }).trim();
writeFileSync(packageJsonFilePath, JSON.stringify(packageJsonValue, /*replacer:*/ undefined, /*space:*/ 4));
writeFileSync(tsFilePath, modifiedTsFileContents);
}