poe-code 7.0.0 → 7.0.2
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/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/packages/safejs/dist/cli.d.ts +1 -0
- package/packages/safejs/dist/cli.js +20 -6
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { mkdir, readFile, realpath, stat, writeFile } from "node:fs/promises";
|
|
2
3
|
import path, { dirname, extname } from "node:path";
|
|
3
4
|
import { formatWithOptions } from "node:util";
|
|
4
|
-
import {
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
5
6
|
import { hasOwnErrorCode } from "./error-codes.js";
|
|
6
7
|
import { formatInterpreterError } from "./error/format.js";
|
|
7
8
|
import { replaceErrorStack } from "./error/shape.js";
|
|
@@ -548,8 +549,21 @@ class CliExitError extends Error {
|
|
|
548
549
|
this.exitCode = exitCode;
|
|
549
550
|
}
|
|
550
551
|
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
}
|
|
552
|
+
async function isDirectExecution(entryPoint) {
|
|
553
|
+
if (typeof entryPoint !== "string" || entryPoint.length === 0) {
|
|
554
|
+
return false;
|
|
555
|
+
}
|
|
556
|
+
try {
|
|
557
|
+
const [resolvedEntryPoint, resolvedModule] = await Promise.all([
|
|
558
|
+
realpath(path.resolve(entryPoint)),
|
|
559
|
+
realpath(fileURLToPath(import.meta.url))
|
|
560
|
+
]);
|
|
561
|
+
return resolvedEntryPoint === resolvedModule;
|
|
562
|
+
}
|
|
563
|
+
catch {
|
|
564
|
+
return false;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
if (await isDirectExecution(process.argv[1])) {
|
|
568
|
+
process.exitCode = await runCli(process.argv.slice(2));
|
|
555
569
|
}
|