All checks were successful
CI / Grammar, queries & corpus (pull_request) Successful in 17s
37 lines
1.5 KiB
JavaScript
37 lines
1.5 KiB
JavaScript
// Between two Gram releases, @gram-lang/parser comes from a tarball packed
|
|
// from `gram.ref` (vendor/), awaiting the release named in
|
|
// `gram.parserRelease`. Fails as soon as that release is on npm, so the
|
|
// tarball never outlives it: CI runs this on every push and once a week.
|
|
import { execFileSync } from "node:child_process";
|
|
import { pkg } from "./conformance.mjs";
|
|
|
|
const spec = pkg.devDependencies["@gram-lang/parser"];
|
|
if (!spec.startsWith("file:")) {
|
|
console.log(`@gram-lang/parser pinned to ${spec} on npm.`);
|
|
process.exit(0);
|
|
}
|
|
const release = pkg.gram.parserRelease;
|
|
if (!release) {
|
|
console.error(`@gram-lang/parser is a tarball (${spec}) but gram.parserRelease names no release to wait for.`);
|
|
process.exit(1);
|
|
}
|
|
let published = false;
|
|
try {
|
|
published = execFileSync("npm", ["view", `@gram-lang/parser@${release}`, "version"], { encoding: "utf8" }).trim() === release;
|
|
} catch (e) {
|
|
if (!/E404/.test(String(e.stderr ?? e))) {
|
|
console.warn(`Could not ask npm about @gram-lang/parser@${release}: ${e.message}`);
|
|
process.exit(0);
|
|
}
|
|
}
|
|
if (published) {
|
|
console.error(
|
|
[
|
|
`@gram-lang/parser@${release} is published: drop the vendored tarball.`,
|
|
` 1. package.json: "@gram-lang/parser": "${release}", gram.ref: the v.${release} tag's commit, remove gram.parserRelease`,
|
|
" 2. delete vendor/, run npm install, then npm run conformance:fetch && npm run conformance && npm run oracle",
|
|
].join("\n"),
|
|
);
|
|
process.exit(1);
|
|
}
|
|
console.log(`@gram-lang/parser@${release} not published yet: the vendored tarball (${spec}) stays.`);
|