audit-tools 0.52.4 → 0.52.5
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/package.json +1 -1
- package/remediate-code.mjs +16 -3
package/package.json
CHANGED
package/remediate-code.mjs
CHANGED
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
// to dist/remediate/index.js.
|
|
6
6
|
|
|
7
7
|
import { fileURLToPath } from "url";
|
|
8
|
-
import { pathToFileURL } from "url";
|
|
9
8
|
import { dirname, join } from "path";
|
|
10
|
-
import { existsSync, readdirSync, statSync } from "fs";
|
|
9
|
+
import { existsSync, readdirSync, statSync, realpathSync } from "fs";
|
|
11
10
|
import { spawnSync } from "child_process";
|
|
12
11
|
|
|
13
12
|
// The installer (B2) is imported LAZILY inside main() only when an install verb
|
|
@@ -190,7 +189,21 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
190
189
|
applyWrapperExitAction(getWrapperExitAction(result));
|
|
191
190
|
}
|
|
192
191
|
|
|
193
|
-
|
|
192
|
+
// sites-pinned: tests/remediate/remediate-code.test.ts
|
|
193
|
+
// npm's POSIX bin is a symlink. Node resolves the module URL, but argv[1]
|
|
194
|
+
// retains the bin path; compare filesystem identities while keeping imports inert.
|
|
195
|
+
function invokedDirectly() {
|
|
196
|
+
try {
|
|
197
|
+
return process.argv[1] != null &&
|
|
198
|
+
realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url));
|
|
199
|
+
} catch (error) {
|
|
200
|
+
if (error && typeof error === "object" && "code" in error &&
|
|
201
|
+
(error.code === "ENOENT" || error.code === "ENOTDIR")) return false;
|
|
202
|
+
throw error; // unexpected filesystem failures must not become a silent CLI success
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (invokedDirectly()) {
|
|
194
207
|
main().catch((error) => {
|
|
195
208
|
console.error(error?.stack ?? String(error));
|
|
196
209
|
process.exit(1);
|