Skip to content

Commit

Permalink
fix: convert 'suggest yarn install' script from Shell to JS (#32356)
Browse files Browse the repository at this point in the history
fix: convert suggest yarn install script from Shell to JS
  • Loading branch information
OnkarRuikar authored Feb 20, 2024
1 parent 20ee91c commit 3dcf0a3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
9 changes: 0 additions & 9 deletions .husky/update-history

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"type": "module",
"scripts": {
"postinstall": "sh ./.husky/update-history",
"postinstall": "node scripts/update-history.js",
"build": "env-cmd --silent cross-env CONTENT_ROOT=files BUILD_OUT_ROOT=build yari-build",
"content": "env-cmd --silent cross-env CONTENT_ROOT=files yari-tool",
"filecheck": "env-cmd --silent cross-env CONTENT_ROOT=files yari-filecheck --cwd=.",
Expand Down
16 changes: 16 additions & 0 deletions scripts/update-history.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* This script stores the 'main' branch's HEAD commit hash in .husky/_/history
* The stored commit hash is used by the post-merge script .husky/post-merge
*/

import fs from "node:fs";
import { execGit } from "./utils.js";

const HUSKY_ROOT = ".husky/_/";
const HISTORY_FILE = HUSKY_ROOT + "history";

const branch = execGit(["rev-parse", "--abbrev-ref", "HEAD"], { cwd: "." });
if (branch === "main" && fs.existsSync(HUSKY_ROOT)) {
const hash = execGit(["rev-parse", "HEAD"], { cwd: "." });
fs.writeFileSync(HISTORY_FILE, hash);
}

0 comments on commit 3dcf0a3

Please sign in to comment.