edfcore 0.4.174 → 0.4.177
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/cli.js +17 -0
- package/dist/cli.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/docs/CHANGELOG.md +22 -0
- package/package.json +1 -1
- package/src/cli.ts +21 -1
- package/src/constants.ts +1 -1
package/dist/cli.js
CHANGED
|
@@ -23,6 +23,23 @@ import { isEdfError } from './errors.js';
|
|
|
23
23
|
const fs = nodeFsPromises;
|
|
24
24
|
const proc = nodeProcess.default ??
|
|
25
25
|
nodeProcess;
|
|
26
|
+
/*
|
|
27
|
+
* A closed pipe is not an error, and Node treats it as one.
|
|
28
|
+
*
|
|
29
|
+
* `edfcore signals big.edf | head -1` closes stdout while the CLI is still writing. The write
|
|
30
|
+
* fails with EPIPE, nothing is listening for `error` on the stream, and Node's default is to
|
|
31
|
+
* rethrow it as an uncaught exception — so a command documented "for grep and awk" answered a
|
|
32
|
+
* perfectly ordinary shell idiom with a kilobyte of stack trace on stderr. `head`, `less`,
|
|
33
|
+
* `grep -m1` and a `jq` that exits early all do this.
|
|
34
|
+
*
|
|
35
|
+
* Swallowed rather than reported: the consumer got what it asked for and stopped listening, which
|
|
36
|
+
* is what it is entitled to do. The remaining writes are dropped by the same handler, since the
|
|
37
|
+
* stream stays broken (fixed in 0.4.175).
|
|
38
|
+
*/
|
|
39
|
+
proc.stdout.on('error', (error) => {
|
|
40
|
+
if (error?.code !== 'EPIPE')
|
|
41
|
+
throw error;
|
|
42
|
+
});
|
|
26
43
|
const io = {
|
|
27
44
|
readFile: (path) => fs.readFile(path),
|
|
28
45
|
out: (text) => {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AAEH,8FAA8F;AAC9F,2F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;IAC1B,CAAC;CACF,CAAC;AAEF,KAAK,UAAU,IAAI;IACjB,IAAI,CAAC;QACH,IAAI,CAAC,QAAQ,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAClE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,6FAA6F;QAC7F,4CAA4C;QAC5C,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5F,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,OAAO,IAAI,CAAC,CAAC;QAC3C,4FAA4F;QAC5F,0FAA0F;QAC1F,gBAAgB;QAChB,IAAI,CAAC,QAAQ,GAAG,KAAK,YAAY,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;AACH,CAAC;AAED,8FAA8F;AAC9F,+FAA+F;AAC/F,6DAA6D;AAC7D,KAAK,IAAI,EAAE,CAAC"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -109,5 +109,5 @@ export declare const SIGNAL_FIELD_BLOCK_OFFSETS: {
|
|
|
109
109
|
readonly reserved: 224;
|
|
110
110
|
};
|
|
111
111
|
/** Published package version. Kept in sync with package.json by a test. */
|
|
112
|
-
export declare const VERSION = "0.4.
|
|
112
|
+
export declare const VERSION = "0.4.177";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
package/docs/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,28 @@ alone does not tell you whether you were affected.
|
|
|
6
6
|
edfcore is pre-1.0. Patch releases have carried behaviour changes where the old behaviour was a
|
|
7
7
|
defect; those are called out below.
|
|
8
8
|
|
|
9
|
+
## 0.4.177
|
|
10
|
+
|
|
11
|
+
- **Added** a test that runs the CLI as a process with its output piped into `head`. Every other
|
|
12
|
+
CLI test drives `runCli` through an injected `CliIo`, which is why they need no build - and why
|
|
13
|
+
nothing covered `cli.ts`, where the EPIPE crash 0.4.175 fixed actually lived. It skips when
|
|
14
|
+
`dist/cli.js` is absent rather than passing on a binary it never ran.
|
|
15
|
+
|
|
16
|
+
## 0.4.176
|
|
17
|
+
|
|
18
|
+
Never released. `npm run check` failed on formatting in the new test file, and the release run had
|
|
19
|
+
already bumped the version by the time it stopped, which consumed the number before a tag was cut.
|
|
20
|
+
The pipe test that carried this heading shipped in `0.4.177`.
|
|
21
|
+
|
|
22
|
+
## 0.4.175
|
|
23
|
+
|
|
24
|
+
- **Fixed** the CLI crashing when its output is piped into something that stops reading.
|
|
25
|
+
`edfcore signals big.edf | head -1` closed stdout mid-write; nothing listened for `error` on the
|
|
26
|
+
stream, so Node rethrew EPIPE as an uncaught exception and printed a kilobyte of stack trace to
|
|
27
|
+
stderr. `head`, `less`, `grep -m1` and a `jq` that exits early all do this, and `signals` is
|
|
28
|
+
documented "for grep and awk". A closed pipe is now swallowed: the consumer got what it asked for
|
|
29
|
+
and is entitled to stop listening. Every other stdout error still throws.
|
|
30
|
+
|
|
9
31
|
## 0.4.174
|
|
10
32
|
|
|
11
33
|
- **Added** `FormatHeaderOptions.diagnosticsHint`, and turned it off in `edfcore header`. That
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -28,7 +28,10 @@ interface NodeFs {
|
|
|
28
28
|
interface NodeProcess {
|
|
29
29
|
readonly argv: readonly string[];
|
|
30
30
|
exitCode: number | undefined;
|
|
31
|
-
readonly stdout: {
|
|
31
|
+
readonly stdout: {
|
|
32
|
+
write(text: string): unknown;
|
|
33
|
+
on(event: string, listener: (error: { code?: string }) => void): unknown;
|
|
34
|
+
};
|
|
32
35
|
readonly stderr: { write(text: string): unknown };
|
|
33
36
|
}
|
|
34
37
|
|
|
@@ -37,6 +40,23 @@ const proc: NodeProcess =
|
|
|
37
40
|
(nodeProcess as unknown as { default?: NodeProcess }).default ??
|
|
38
41
|
(nodeProcess as unknown as NodeProcess);
|
|
39
42
|
|
|
43
|
+
/*
|
|
44
|
+
* A closed pipe is not an error, and Node treats it as one.
|
|
45
|
+
*
|
|
46
|
+
* `edfcore signals big.edf | head -1` closes stdout while the CLI is still writing. The write
|
|
47
|
+
* fails with EPIPE, nothing is listening for `error` on the stream, and Node's default is to
|
|
48
|
+
* rethrow it as an uncaught exception — so a command documented "for grep and awk" answered a
|
|
49
|
+
* perfectly ordinary shell idiom with a kilobyte of stack trace on stderr. `head`, `less`,
|
|
50
|
+
* `grep -m1` and a `jq` that exits early all do this.
|
|
51
|
+
*
|
|
52
|
+
* Swallowed rather than reported: the consumer got what it asked for and stopped listening, which
|
|
53
|
+
* is what it is entitled to do. The remaining writes are dropped by the same handler, since the
|
|
54
|
+
* stream stays broken (fixed in 0.4.175).
|
|
55
|
+
*/
|
|
56
|
+
proc.stdout.on('error', (error) => {
|
|
57
|
+
if (error?.code !== 'EPIPE') throw error;
|
|
58
|
+
});
|
|
59
|
+
|
|
40
60
|
const io: CliIo = {
|
|
41
61
|
readFile: (path) => fs.readFile(path),
|
|
42
62
|
out: (text) => {
|
package/src/constants.ts
CHANGED