runneryard 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/runneryard.mjs +12 -3
- package/package.json +1 -1
package/bin/runneryard.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
|
-
import { chmod, mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
4
|
+
import { chmod, mkdir, readFile, realpath, rename, rm, writeFile } from "node:fs/promises";
|
|
5
5
|
import { homedir, tmpdir } from "node:os";
|
|
6
6
|
import { dirname, join } from "node:path";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
@@ -108,8 +108,17 @@ async function main() {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
async function isEntrypoint(modulePath = fileURLToPath(import.meta.url), argumentPath = process.argv[1]) {
|
|
112
|
+
if (!argumentPath) return false;
|
|
113
|
+
try {
|
|
114
|
+
return (await realpath(modulePath)) === (await realpath(argumentPath));
|
|
115
|
+
} catch {
|
|
116
|
+
return modulePath === argumentPath;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (await isEntrypoint()) {
|
|
112
121
|
await main();
|
|
113
122
|
}
|
|
114
123
|
|
|
115
|
-
export { expectedChecksum, forwardSignals, main, targetFor };
|
|
124
|
+
export { expectedChecksum, forwardSignals, isEntrypoint, main, targetFor };
|