Skip to content

Commit 7fb0012

Browse files
committed
fix: replace MSYS cat with cross-platform read-stdin tool in stdin tests
MSYS cat from Git for Windows crashes with MapViewOfFileEx errors when stdin is set to Stdio::null(), causing CI failures on Windows. Replace with a Node.js read-stdin tool that handles null stdin gracefully.
1 parent 4176c4c commit 7fb0012

7 files changed

Lines changed: 18 additions & 11 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "other",
33
"scripts": {
4-
"read-stdin": "cat"
4+
"read-stdin": "read-stdin"
55
}
66
}

crates/vite_task_bin/tests/e2e_snapshots/fixtures/stdin-inheritance/snapshots/multiple tasks get null stdin.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
33
expression: e2e_outputs
44
---
55
> echo from-stdin | vp run -r read-stdin
6-
$ catcache disabled: no cache config
6+
$ read-stdincache disabled: no cache config
77

8-
~/packages/other$ cat
8+
~/packages/other$ read-stdin
99

1010

1111
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
@@ -17,9 +17,9 @@ Performance: 0% cache hit rate
1717

1818
Task Details:
1919
────────────────────────────────────────────────
20-
[1] stdin-inheritance-test#read-stdin: $ cat
20+
[1] stdin-inheritance-test#read-stdin: $ read-stdin
2121
Cache disabled in task configuration
2222
·······················································
23-
[2] other#read-stdin: ~/packages/other$ cat
23+
[2] other#read-stdin: ~/packages/other$ read-stdin
2424
Cache miss: no previous cache entry found
2525
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

crates/vite_task_bin/tests/e2e_snapshots/fixtures/stdin-inheritance/snapshots/single task no cache inherits stdin.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
33
expression: e2e_outputs
44
---
55
> echo from-stdin | vp run read-stdin
6-
$ catcache disabled: no cache config
6+
$ read-stdincache disabled: no cache config
77
from-stdin
88

99

@@ -16,6 +16,6 @@ Performance: 0% cache hit rate
1616

1717
Task Details:
1818
────────────────────────────────────────────────
19-
[1] stdin-inheritance-test#read-stdin: $ cat
19+
[1] stdin-inheritance-test#read-stdin: $ read-stdin
2020
Cache disabled in task configuration
2121
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

crates/vite_task_bin/tests/e2e_snapshots/fixtures/stdin-inheritance/snapshots/single task with cache gets null stdin.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
33
expression: e2e_outputs
44
---
55
> echo from-stdin | vp run read-stdin-cached
6-
$ cat
6+
$ read-stdin
77

88

99
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
@@ -15,6 +15,6 @@ Performance: 0% cache hit rate
1515

1616
Task Details:
1717
────────────────────────────────────────────────
18-
[1] stdin-inheritance-test#read-stdin-cached: $ cat
18+
[1] stdin-inheritance-test#read-stdin-cached: $ read-stdin
1919
Cache miss: no previous cache entry found
2020
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

crates/vite_task_bin/tests/e2e_snapshots/fixtures/stdin-inheritance/vite-task.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"cacheScripts": true,
33
"tasks": {
44
"read-stdin": {
5-
"command": "cat",
5+
"command": "read-stdin",
66
"cache": false
77
},
88
"read-stdin-cached": {
9-
"command": "cat",
9+
"command": "read-stdin",
1010
"cache": true
1111
}
1212
}

packages/tools/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"print-file": "./src/print-file.ts",
88
"print-env": "./src/print-env.js",
99
"json-edit": "./src/json-edit.ts",
10+
"read-stdin": "./src/read-stdin.js",
1011
"replace-file-content": "./src/replace-file-content.ts"
1112
},
1213
"dependencies": {

packages/tools/src/read-stdin.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env node
2+
3+
// Cross-platform cat replacement: reads all of stdin and writes it to stdout.
4+
// Unlike MSYS cat on Windows, this handles Stdio::null() gracefully by
5+
// receiving an immediate EOF rather than crashing.
6+
process.stdin.pipe(process.stdout);

0 commit comments

Comments
 (0)