-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use shell for last commit and add comapre script
- Loading branch information
Showing
4 changed files
with
58 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { readFile } from "fs/promises"; | ||
import path from "path"; | ||
import { fileURLToPath } from "url"; | ||
|
||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
const CURRENT_COMMIT_VARIABLE_NAME = "COMPAT_TABLE_COMMIT"; | ||
|
||
async function getCurrentCommit() { | ||
const target = path.join( | ||
__dirname, | ||
"..", | ||
"..", | ||
"packages", | ||
"babel-compat-data", | ||
"scripts", | ||
"download-compat-table.sh" | ||
); | ||
const lines = (await readFile(target, { encoding: "utf-8" })).split("\n"); | ||
|
||
for (const line of lines) { | ||
if (line.includes(CURRENT_COMMIT_VARIABLE_NAME)) { | ||
return line.split("=").at(1); | ||
} | ||
} | ||
|
||
return undefined; | ||
} | ||
|
||
async function checkCurrentCommit(lastCommit) { | ||
if (typeof lastCommit !== "string") { | ||
throw new Error(`Last commit should be provided but got ${lastCommit}`); | ||
} | ||
|
||
const currentCommit = await getCurrentCommit(); | ||
if (typeof lastCommit !== "string") { | ||
throw new Error("Not valid current commit found: ${currentCommit}"); | ||
} | ||
|
||
console.log("last commit :", lastCommit); | ||
console.log("current commit :", currentCommit); | ||
|
||
if (lastCommit === currentCommit) { | ||
throw new Error("compat-data doesn't need to be updated"); | ||
} | ||
|
||
return lastCommit; | ||
} | ||
|
||
checkCurrentCommit(process.argv[2]).then(console.log); |
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
set -e | ||
export GIT_DIR=./packages/babel-compat-data/build/compat-table | ||
git fetch -q origin HEAD | ||
git rev-parse FETCH_HEAD |