(cmd, args, { log, stdioString = true, ...opts } = {})
| 123 | t.teardown(() => moveRemove(join(path, 'node.exe'))) |
| 124 | |
| 125 | const spawnPath = (cmd, args, { log, stdioString = true, ...opts } = {}) => { |
| 126 | if (cmd.endsWith('bash.exe')) { |
| 127 | // only cygwin *requires* the -l, but the others are ok with it |
| 128 | args.unshift('-l') |
| 129 | } |
| 130 | if (cmd.toLowerCase().endsWith('powershell.exe') || cmd.toLowerCase().endsWith('pwsh.exe')) { |
| 131 | // pwsh *requires* the -Command, Windows PowerShell defaults to it |
| 132 | args.unshift('-Command') |
| 133 | // powershell requires escaping double-quotes for this test |
| 134 | args = args.map(elem => elem.replaceAll('"', '\\"')) |
| 135 | } |
| 136 | const result = spawnSync(`"${cmd}"`, args, { |
| 137 | // don't hit the registry for the update check |
| 138 | env: { PATH: path, npm_config_update_notifier: 'false' }, |
| 139 | cwd: path, |
| 140 | windowsHide: true, |
| 141 | shell: true, |
| 142 | ...opts, |
| 143 | }) |
| 144 | if (stdioString) { |
| 145 | result.stdout = result.stdout?.toString()?.trim() |
| 146 | result.stderr = result.stderr?.toString()?.trim() |
| 147 | } |
| 148 | return { |
| 149 | status: result.status, |
| 150 | signal: result.signal, |
| 151 | stdout: result.stdout, |
| 152 | stderr: result.stderr, |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | const getWslVersion = (cmd) => { |
| 157 | const defaultVersion = 1 |
no test coverage detected