forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add gitHead to package.json in all release workflows (microsoft#58135)
- Loading branch information
1 parent
e62418e
commit c50ec79
Showing
7 changed files
with
29 additions
and
3 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
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 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 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 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 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,24 @@ | ||
import { execFileSync } from "child_process"; | ||
import { | ||
readFileSync, | ||
writeFileSync, | ||
} from "fs"; | ||
import { | ||
dirname, | ||
resolve, | ||
} from "path"; | ||
|
||
const packageJsonFilePath = process.argv[2]; | ||
if (!packageJsonFilePath) { | ||
console.error("Usage: node addPackageJsonGitHead.mjs <package.json location>"); | ||
process.exit(1); | ||
} | ||
|
||
const packageJsonValue = JSON.parse(readFileSync(packageJsonFilePath, "utf8")); | ||
|
||
const cwd = dirname(resolve(packageJsonFilePath)); | ||
const gitHead = execFileSync("git", ["rev-parse", "HEAD"], { cwd, encoding: "utf8" }).trim(); | ||
|
||
packageJsonValue.gitHead = gitHead; | ||
|
||
writeFileSync(packageJsonFilePath, JSON.stringify(packageJsonValue, undefined, 4) + "\n"); |
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