返回 CodeWhale
command-shims.mjs
根目录 / crates / tui / plugins / computer-use / tests / fixtures / command-shims.mjs
1 // Test-process preload: substitute only explicitly supplied command fixtures.
2 // Node loads it before production imports, preserving argument arrays, pipes,
3 // exit codes and cancellation on every OS without POSIX shebang assumptions.
4 import cp from 'node:child_process';
5 import fs from 'node:fs';
6 import path from 'node:path';
7 import { syncBuiltinESMExports } from 'node:module';
8 const original = cp.spawn;
9 cp.spawn = function(command, args = [], options) {
10 const dir = process.env.CU_COMMAND_FIXTURES;
11 if (dir && ['ssh', 'scp', 'hdc'].includes(command)) {
12 const script = path.join(dir, `${command}.cjs`);
13 if (fs.existsSync(script)) return original(process.execPath, [script, ...args], options);
14 }
15 return original(command, args, options);
16 };
17 syncBuiltinESMExports();
18
18 lines Plain Text