depcurfew 1.0.0 → 1.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/README.md +349 -46
- package/dist/cli.js +28 -4
- package/dist/index.d.ts +679 -28
- package/dist/index.js +1 -1
- package/dist/run-BBZUJJq-.js +33143 -0
- package/package.json +13 -2
- package/schema.json +24 -8
- package/dist/run-D7KMlsVh.js +0 -6595
package/dist/cli.js
CHANGED
|
@@ -1,15 +1,39 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { R as colorsFor, t as run } from "./run-BBZUJJq-.js";
|
|
3
3
|
// src/cli.ts
|
|
4
|
+
/**
|
|
5
|
+
* Output to a stream whose reader has gone (depcurfew doctor --sarif | head -1) fails with EPIPE, which Node reports
|
|
6
|
+
* as an 'error' event that nobody handles: a stack trace and exit code 1. The rest of the output is dropped instead,
|
|
7
|
+
* quietly, and the command still ends with its own exit code.
|
|
8
|
+
*/
|
|
9
|
+
function quietWhenClosed(stream) {
|
|
10
|
+
let closed = false;
|
|
11
|
+
stream.on("error", (error) => {
|
|
12
|
+
if (error.code === "EPIPE" || error.code === "ERR_STREAM_DESTROYED") {
|
|
13
|
+
closed = true;
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
closed = true;
|
|
17
|
+
if (stream !== process.stderr) process.stderr.write(`depcurfew: cannot write the output: ${error.message}\n`);
|
|
18
|
+
process.exitCode = 1;
|
|
19
|
+
});
|
|
20
|
+
return (text) => {
|
|
21
|
+
if (!closed) stream.write(text);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
4
24
|
run(process.argv.slice(2), {
|
|
5
|
-
stdout: (
|
|
6
|
-
stderr: (
|
|
25
|
+
stdout: quietWhenClosed(process.stdout),
|
|
26
|
+
stderr: quietWhenClosed(process.stderr),
|
|
7
27
|
colors: {
|
|
8
28
|
stdout: colorsFor(process.stdout, process.env),
|
|
9
29
|
stderr: colorsFor(process.stderr, process.env)
|
|
30
|
+
},
|
|
31
|
+
terminal: {
|
|
32
|
+
stdout: process.stdout.isTTY === true,
|
|
33
|
+
stderr: process.stderr.isTTY === true
|
|
10
34
|
}
|
|
11
35
|
}).then((code) => {
|
|
12
|
-
process.exitCode = code;
|
|
36
|
+
if (process.exitCode === void 0 || process.exitCode === 0) process.exitCode = code;
|
|
13
37
|
}, (error) => {
|
|
14
38
|
process.stderr.write(`depcurfew: unexpected error: ${error instanceof Error ? error.stack : String(error)}\n`);
|
|
15
39
|
process.exitCode = 1;
|