fauxnix-cli 2.1.0 → 2.1.1
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/facade-sea.cjs +24 -22
- package/dist/parser.js +15 -0
- package/dist/ps-host.js +20 -22
- package/package.json +1 -1
package/dist/facade-sea.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
globalThis.__FAUXNIX_VERSION__="2.1.
|
|
1
|
+
globalThis.__FAUXNIX_VERSION__="2.1.1";globalThis.__FAUXNIX_ENGINES_NODE__=">=22.20.0";
|
|
2
2
|
"use strict";
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -3967,7 +3967,12 @@ function tokenize(input) {
|
|
|
3967
3967
|
else matched = fdDigits + ">";
|
|
3968
3968
|
}
|
|
3969
3969
|
advance = matched.length - fdDigits.length;
|
|
3970
|
+
if (matched === "1>") matched = ">";
|
|
3971
|
+
else if (matched === "1>>") matched = ">>";
|
|
3970
3972
|
fdDigits = "";
|
|
3973
|
+
} else if (matched === ">" && input.startsWith("&2", i + 1) && !/[^\s;|&<>()]/.test(input[i + 3] ?? " ")) {
|
|
3974
|
+
matched = "1>&2";
|
|
3975
|
+
advance = 3;
|
|
3971
3976
|
}
|
|
3972
3977
|
if (matched === "<<") {
|
|
3973
3978
|
throw new FauxnixParseError(
|
|
@@ -4890,6 +4895,9 @@ function parseCommand(input) {
|
|
|
4890
4895
|
next();
|
|
4891
4896
|
continue;
|
|
4892
4897
|
}
|
|
4898
|
+
if (t.type === "OP" && /^\d+[<>]/.test(t.op) && !isRedirectOp(t.op)) {
|
|
4899
|
+
normalizeRedirect(t.op);
|
|
4900
|
+
}
|
|
4893
4901
|
if (t.type === "OP" && isRedirectOp(t.op)) {
|
|
4894
4902
|
const op = t.op;
|
|
4895
4903
|
next();
|
|
@@ -16580,6 +16588,13 @@ var PowerShellHost = class {
|
|
|
16580
16588
|
windowsHide: true
|
|
16581
16589
|
});
|
|
16582
16590
|
this.proc = child;
|
|
16591
|
+
child.stdin.on("error", (e) => {
|
|
16592
|
+
if (this.proc !== child) return;
|
|
16593
|
+
this.closeErr = e;
|
|
16594
|
+
this.closed = true;
|
|
16595
|
+
this.failWaiters(e);
|
|
16596
|
+
this.cancelNativeCapture();
|
|
16597
|
+
});
|
|
16583
16598
|
child.stdout.on("data", (d) => {
|
|
16584
16599
|
if (this.proc !== child) return;
|
|
16585
16600
|
this.onStdout(d);
|
|
@@ -16593,6 +16608,7 @@ var PowerShellHost = class {
|
|
|
16593
16608
|
this.closeErr = e;
|
|
16594
16609
|
this.closed = true;
|
|
16595
16610
|
this.failWaiters(e);
|
|
16611
|
+
this.cancelNativeCapture();
|
|
16596
16612
|
});
|
|
16597
16613
|
child.on("close", (c) => {
|
|
16598
16614
|
if (this.proc !== child) return;
|
|
@@ -16600,6 +16616,7 @@ var PowerShellHost = class {
|
|
|
16600
16616
|
this.closed = true;
|
|
16601
16617
|
this.proc = null;
|
|
16602
16618
|
this.failWaiters(new Error("fauxnix: powershell host closed"));
|
|
16619
|
+
this.cancelNativeCapture();
|
|
16603
16620
|
});
|
|
16604
16621
|
try {
|
|
16605
16622
|
const readyLine = await this.nextReadyLine(READY_TIMEOUT_MS);
|
|
@@ -16696,7 +16713,7 @@ var PowerShellHost = class {
|
|
|
16696
16713
|
limits?.stderrMode ?? "capture",
|
|
16697
16714
|
limits?.stderrLimit ?? DEFAULT_STDERR_LIMIT,
|
|
16698
16715
|
limits?.nativeStderrSpoolPath,
|
|
16699
|
-
timeoutMs
|
|
16716
|
+
timeoutMs
|
|
16700
16717
|
);
|
|
16701
16718
|
void nativePromise.catch(() => void 0);
|
|
16702
16719
|
while (!end) {
|
|
@@ -16722,25 +16739,7 @@ var PowerShellHost = class {
|
|
|
16722
16739
|
end = f;
|
|
16723
16740
|
}
|
|
16724
16741
|
}
|
|
16725
|
-
|
|
16726
|
-
let markerTimer;
|
|
16727
|
-
try {
|
|
16728
|
-
const captured = await Promise.race([
|
|
16729
|
-
nativePromise,
|
|
16730
|
-
new Promise((_, reject) => {
|
|
16731
|
-
markerTimer = setTimeout(
|
|
16732
|
-
() => reject(new Error("fauxnix: native stderr marker missing")),
|
|
16733
|
-
2e3
|
|
16734
|
-
);
|
|
16735
|
-
})
|
|
16736
|
-
]);
|
|
16737
|
-
nativeBytes = captured.bytesSeen;
|
|
16738
|
-
} catch (e) {
|
|
16739
|
-
this.cancelNativeCapture();
|
|
16740
|
-
if (e instanceof NativeStderrSpoolError) throw e;
|
|
16741
|
-
} finally {
|
|
16742
|
-
if (markerTimer) clearTimeout(markerTimer);
|
|
16743
|
-
}
|
|
16742
|
+
const { bytesSeen: nativeBytes } = await nativePromise;
|
|
16744
16743
|
const capturedErr = Buffer.from(Buffer.concat(err));
|
|
16745
16744
|
let native = Buffer.alloc(0);
|
|
16746
16745
|
let nativeTruncated = false;
|
|
@@ -16777,7 +16776,10 @@ var PowerShellHost = class {
|
|
|
16777
16776
|
const timer = setTimeout(() => {
|
|
16778
16777
|
if (this.nativeCapture?.id !== id2) return;
|
|
16779
16778
|
const state = this.nativeCapture;
|
|
16780
|
-
const failure = state.ioError ??
|
|
16779
|
+
const failure = state.ioError ?? Object.assign(
|
|
16780
|
+
new Error("fauxnix: native stderr marker timed out"),
|
|
16781
|
+
{ timedOut: true }
|
|
16782
|
+
);
|
|
16781
16783
|
this.closeNativeSpool(state);
|
|
16782
16784
|
this.nativeCapture = null;
|
|
16783
16785
|
reject(failure);
|
package/dist/parser.js
CHANGED
|
@@ -93,8 +93,20 @@ export function tokenize(input) {
|
|
|
93
93
|
}
|
|
94
94
|
// the fd digits were consumed earlier; advance past the operator tail only
|
|
95
95
|
advance = matched.length - fdDigits.length;
|
|
96
|
+
// fd 1 is stdout: `1>f` / `1>>f` are the same redirects as `>f` / `>>f`
|
|
97
|
+
if (matched === '1>')
|
|
98
|
+
matched = '>';
|
|
99
|
+
else if (matched === '1>>')
|
|
100
|
+
matched = '>>';
|
|
96
101
|
fdDigits = '';
|
|
97
102
|
}
|
|
103
|
+
else if (matched === '>' &&
|
|
104
|
+
input.startsWith('&2', i + 1) &&
|
|
105
|
+
!/[^\s;|&<>()]/.test(input[i + 3] ?? ' ')) {
|
|
106
|
+
// `>&2` is shorthand for `1>&2`
|
|
107
|
+
matched = '1>&2';
|
|
108
|
+
advance = 3;
|
|
109
|
+
}
|
|
98
110
|
if (matched === '<<') {
|
|
99
111
|
throw new FauxnixParseError('fauxnix: heredocs (<<) are not supported yet. Pass the text via echo pipe or a temp file instead.');
|
|
100
112
|
}
|
|
@@ -1264,6 +1276,9 @@ export function parseCommand(input) {
|
|
|
1264
1276
|
next();
|
|
1265
1277
|
continue;
|
|
1266
1278
|
}
|
|
1279
|
+
if (t.type === 'OP' && /^\d+[<>]/.test(t.op) && !isRedirectOp(t.op)) {
|
|
1280
|
+
normalizeRedirect(t.op);
|
|
1281
|
+
}
|
|
1267
1282
|
if (t.type === 'OP' && isRedirectOp(t.op)) {
|
|
1268
1283
|
const op = t.op;
|
|
1269
1284
|
next();
|
package/dist/ps-host.js
CHANGED
|
@@ -377,6 +377,17 @@ export class PowerShellHost {
|
|
|
377
377
|
windowsHide: true,
|
|
378
378
|
});
|
|
379
379
|
this.proc = child;
|
|
380
|
+
child.stdin.on('error', (e) => {
|
|
381
|
+
// A closed host input pipe reports EPIPE asynchronously; write()'s
|
|
382
|
+
// try/catch cannot contain it. Fail this request through the normal
|
|
383
|
+
// dead-host path and leave the next invocation free to start again.
|
|
384
|
+
if (this.proc !== child)
|
|
385
|
+
return;
|
|
386
|
+
this.closeErr = e;
|
|
387
|
+
this.closed = true;
|
|
388
|
+
this.failWaiters(e);
|
|
389
|
+
this.cancelNativeCapture();
|
|
390
|
+
});
|
|
380
391
|
child.stdout.on('data', (d) => {
|
|
381
392
|
if (this.proc !== child)
|
|
382
393
|
return;
|
|
@@ -393,6 +404,7 @@ export class PowerShellHost {
|
|
|
393
404
|
this.closeErr = e;
|
|
394
405
|
this.closed = true;
|
|
395
406
|
this.failWaiters(e);
|
|
407
|
+
this.cancelNativeCapture();
|
|
396
408
|
});
|
|
397
409
|
child.on('close', (c) => {
|
|
398
410
|
if (this.proc !== child)
|
|
@@ -401,6 +413,7 @@ export class PowerShellHost {
|
|
|
401
413
|
this.closed = true;
|
|
402
414
|
this.proc = null;
|
|
403
415
|
this.failWaiters(new Error('fauxnix: powershell host closed'));
|
|
416
|
+
this.cancelNativeCapture();
|
|
404
417
|
});
|
|
405
418
|
try {
|
|
406
419
|
const readyLine = await this.nextReadyLine(READY_TIMEOUT_MS);
|
|
@@ -512,7 +525,7 @@ export class PowerShellHost {
|
|
|
512
525
|
let outSeq = 0;
|
|
513
526
|
let errSeq = 0;
|
|
514
527
|
let end = null;
|
|
515
|
-
const nativePromise = this.beginNativeCapture(id, limits?.stderrMode ?? 'capture', limits?.stderrLimit ?? DEFAULT_STDERR_LIMIT, limits?.nativeStderrSpoolPath, timeoutMs
|
|
528
|
+
const nativePromise = this.beginNativeCapture(id, limits?.stderrMode ?? 'capture', limits?.stderrLimit ?? DEFAULT_STDERR_LIMIT, limits?.nativeStderrSpoolPath, timeoutMs);
|
|
516
529
|
// collectV2 can leave through a frame timeout before it reaches the await
|
|
517
530
|
// below. Attach a handler immediately so teardown never reports a stray
|
|
518
531
|
// promise rejection; the awaited path still receives the same failure.
|
|
@@ -547,26 +560,11 @@ export class PowerShellHost {
|
|
|
547
560
|
end = f;
|
|
548
561
|
}
|
|
549
562
|
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
new Promise((_, reject) => {
|
|
556
|
-
markerTimer = setTimeout(() => reject(new Error('fauxnix: native stderr marker missing')), 2000);
|
|
557
|
-
}),
|
|
558
|
-
]);
|
|
559
|
-
nativeBytes = captured.bytesSeen;
|
|
560
|
-
}
|
|
561
|
-
catch (e) {
|
|
562
|
-
this.cancelNativeCapture();
|
|
563
|
-
if (e instanceof NativeStderrSpoolError)
|
|
564
|
-
throw e;
|
|
565
|
-
}
|
|
566
|
-
finally {
|
|
567
|
-
if (markerTimer)
|
|
568
|
-
clearTimeout(markerTimer);
|
|
569
|
-
}
|
|
563
|
+
// The end frame and native marker arrive on independent pipes. Finishing
|
|
564
|
+
// stdout does not complete the request: cancellation, pipe failure and
|
|
565
|
+
// the original deadline still apply while native stderr is pending.
|
|
566
|
+
// Let invokeSerial handle failures so it also removes partial spools.
|
|
567
|
+
const { bytesSeen: nativeBytes } = await nativePromise;
|
|
570
568
|
const capturedErr = Buffer.from(Buffer.concat(err));
|
|
571
569
|
let native = Buffer.alloc(0);
|
|
572
570
|
let nativeTruncated = false;
|
|
@@ -601,7 +599,7 @@ export class PowerShellHost {
|
|
|
601
599
|
if (this.nativeCapture?.id !== id)
|
|
602
600
|
return;
|
|
603
601
|
const state = this.nativeCapture;
|
|
604
|
-
const failure = state.ioError ?? new Error('fauxnix: native stderr marker
|
|
602
|
+
const failure = state.ioError ?? Object.assign(new Error('fauxnix: native stderr marker timed out'), { timedOut: true });
|
|
605
603
|
this.closeNativeSpool(state);
|
|
606
604
|
this.nativeCapture = null;
|
|
607
605
|
reject(failure);
|
package/package.json
CHANGED