MCPcopy Create free account
hub / github.com/nodejs/node / matchCmd

Function matchCmd

deps/npm/test/bin/windows-shims.js:241–274  ·  view source on GitHub ↗
(t, cmd, bin, match, params, expected)

Source from the content-addressed store, hash-verified

239 })
240
241 const matchCmd = (t, cmd, bin, match, params, expected) => {
242 const args = []
243 const opts = {}
244
245 switch (basename(cmd).toLowerCase()) {
246 case 'cmd.exe':
247 cmd = `${bin}.cmd`
248 break
249 case 'bash.exe':
250 args.push(bin)
251 break
252 case 'powershell.exe':
253 case 'pwsh.exe':
254 args.push(`${bin}.ps1`)
255 break
256 default:
257 throw new Error('unknown shell')
258 }
259
260 const result = spawnPath(cmd, [...args, ...params], opts)
261
262 // skip the first 3 lines of "npm test" to get the actual script output
263 if (params[0].startsWith('test')) {
264 result.stdout = result.stdout?.toString().split('\n').slice(3).join('\n').trim()
265 }
266
267 t.match(result, {
268 status: 0,
269 signal: null,
270 stderr: '',
271 stdout: expected,
272 ...match,
273 }, `${cmd} ${bin} ${params[0]}`)
274 }
275
276 // Array with command line parameters and expected output
277 const tests = [

Callers 1

windows-shims.jsFile · 0.85

Calls 8

basenameFunction · 0.85
spawnPathFunction · 0.85
sliceMethod · 0.65
matchMethod · 0.65
pushMethod · 0.45
joinMethod · 0.45
splitMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected