fix: export run() to avoid Windows spawnSync issues (#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 #429

Co-authored-by: 阳虎 <yanghu@yanghudeMacBook-Pro.local>
This commit is contained in:
yang1002378395-cmyk
2026-03-17 04:38:47 +08:00
committed by GitHub
parent b57b573085
commit 9fcbe9751c

View File

@@ -1,15 +1,29 @@
#!/usr/bin/env node #!/usr/bin/env node
'use strict'; 'use strict';
const MAX_STDIN = 1024 * 1024; /**
let raw = ''; * Session end marker hook - outputs stdin to stdout unchanged.
process.stdin.setEncoding('utf8'); * Exports run() for in-process execution (avoids spawnSync issues on Windows).
process.stdin.on('data', chunk => { */
if (raw.length < MAX_STDIN) {
const remaining = MAX_STDIN - raw.length; function run(rawInput) {
raw += chunk.substring(0, remaining); return rawInput || '';
} }
});
process.stdin.on('end', () => { // Legacy CLI execution (when run directly)
process.stdout.write(raw); if (require.main === module) {
}); const MAX_STDIN = 1024 * 1024;
let raw = '';
process.stdin.setEncoding('utf8');
process.stdin.on('data', chunk => {
if (raw.length < MAX_STDIN) {
const remaining = MAX_STDIN - raw.length;
raw += chunk.substring(0, remaining);
}
});
process.stdin.on('end', () => {
process.stdout.write(raw);
});
}
module.exports = { run };