Files
paseo/scripts/is-main-module.mjs
T
Mohamed Boudra 47171b419b fix(release): run release scripts as main on Windows runners (#4474)
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.
2026-09-08 11:07:13 +02:00

11 lines
513 B
JavaScript

import path from "node:path";
import { fileURLToPath } from "node:url";
// `import.meta.url === \`file://${process.argv[1]}\`` is false on Windows, where argv[1] is
// `D:\a\...` and the module URL is `file:///D:/a/...`, so a script guarded that way silently
// does nothing on a Windows runner. Compare resolved filesystem paths instead.
export function isMainModule(importMetaUrl, argvPath = process.argv[1]) {
if (!argvPath) return false;
return fileURLToPath(importMetaUrl) === path.resolve(argvPath);
}