Skip to content

Commit 9fcbe97

Browse files
yang1002378395-cmyk阳虎
andauthored
fix: export run() to avoid Windows spawnSync issues (anomalyco#431)
- session-end-marker.js now exports run() function - Enables in-process execution via run-with-flags.js - Avoids spawnSync cross-platform issues on Windows - Maintains backward compatibility with direct CLI execution Fixes anomalyco#429 Co-authored-by: 阳虎 <[email protected]>
1 parent b57b573 commit 9fcbe97

1 file changed

Lines changed: 26 additions & 12 deletions

File tree

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
#!/usr/bin/env node
22
'use strict';
33

4-
const MAX_STDIN = 1024 * 1024;
5-
let raw = '';
6-
process.stdin.setEncoding('utf8');
7-
process.stdin.on('data', chunk => {
8-
if (raw.length < MAX_STDIN) {
9-
const remaining = MAX_STDIN - raw.length;
10-
raw += chunk.substring(0, remaining);
11-
}
12-
});
13-
process.stdin.on('end', () => {
14-
process.stdout.write(raw);
15-
});
4+
/**
5+
* Session end marker hook - outputs stdin to stdout unchanged.
6+
* Exports run() for in-process execution (avoids spawnSync issues on Windows).
7+
*/
8+
9+
function run(rawInput) {
10+
return rawInput || '';
11+
}
12+
13+
// Legacy CLI execution (when run directly)
14+
if (require.main === module) {
15+
const MAX_STDIN = 1024 * 1024;
16+
let raw = '';
17+
process.stdin.setEncoding('utf8');
18+
process.stdin.on('data', chunk => {
19+
if (raw.length < MAX_STDIN) {
20+
const remaining = MAX_STDIN - raw.length;
21+
raw += chunk.substring(0, remaining);
22+
}
23+
});
24+
process.stdin.on('end', () => {
25+
process.stdout.write(raw);
26+
});
27+
}
28+
29+
module.exports = { run };

0 commit comments

Comments
 (0)