15 lines
837 B
JavaScript
15 lines
837 B
JavaScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { spawnSync } from "node:child_process";
|
|
import { readFileSync } from "node:fs";
|
|
const version = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
test("only the exact stable package version can be published", () => {
|
|
for (const ref of [`refs/tags/v${version}`, "refs/heads/main", "refs/tags/v99.99.99", `refs/tags/v${version}-rc.1`, "refs/tags/v1.0.0;echo bad"]) {
|
|
const result = spawnSync(process.execPath, ["scripts/release-version.mjs"], { env: { ...process.env, RELEASE_REF: ref }, encoding: "utf8" });
|
|
if (ref === `refs/tags/v${version}`) {
|
|
assert.equal(result.status, 0);
|
|
assert.equal(result.stdout.trim(), `version=${version}`);
|
|
} else assert.notEqual(result.status, 0, ref);
|
|
}
|
|
});
|