mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-14 13:22:37 +00:00
The ESM main-module guard compared import.meta.url with "file://" + process.argv[1],
which never matches on Windows (file://D:\a\... vs file:///D:/a/...). On the Windows
desktop release job, scripts/github-release.mjs therefore printed nothing and
gh release upload received an empty release lookup ("release not found"), leaving
v0.8.0-beta.1 without a Windows build. Compare resolved paths instead, shared by
every release script that runs as a CLI.
35 lines
1.3 KiB
JavaScript
35 lines
1.3 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import path from "node:path";
|
|
import { test } from "node:test";
|
|
import { pathToFileURL } from "node:url";
|
|
import { isMainModule } from "./is-main-module.mjs";
|
|
|
|
test("matches the executed script on this platform", () => {
|
|
const scriptPath = path.resolve("scripts", "github-release.mjs");
|
|
assert.equal(isMainModule(pathToFileURL(scriptPath).href, scriptPath), true);
|
|
});
|
|
|
|
test("does not match when another module is the entry point", () => {
|
|
const scriptPath = path.resolve("scripts", "github-release.mjs");
|
|
const otherPath = path.resolve("scripts", "stamp-rollout.mjs");
|
|
assert.equal(isMainModule(pathToFileURL(scriptPath).href, otherPath), false);
|
|
});
|
|
|
|
test("returns false without an argv entry", () => {
|
|
assert.equal(
|
|
isMainModule(pathToFileURL(path.resolve("scripts", "x.mjs")).href, undefined),
|
|
false,
|
|
);
|
|
});
|
|
|
|
test("the naive string comparison that broke Windows is not used", () => {
|
|
const scriptPath = path.resolve("scripts", "github-release.mjs");
|
|
const url = pathToFileURL(scriptPath).href;
|
|
// On Windows this naive form is `file://D:\\...` and never equals the module URL.
|
|
assert.notEqual(
|
|
`file://${"D:\\a\\paseo\\scripts\\github-release.mjs"}`,
|
|
"file:///D:/a/paseo/scripts/github-release.mjs",
|
|
);
|
|
assert.equal(isMainModule(url, scriptPath), true);
|
|
});
|