@@ -3,7 +3,7 @@ import type { commands } from '../../src/commands'
33
44import { existsSync } from 'node:fs'
55
6- import { rm } from 'node:fs/promises'
6+ import { chmod , mkdir , rm , writeFile } from 'node:fs/promises'
77import { join } from 'node:path'
88import { fileURLToPath } from 'node:url'
99import { getPort } from 'get-port-please'
@@ -133,7 +133,7 @@ describe('commands', () => {
133133 expect ( res . stderr ) . toBe ( '[error] No command specified.\n' )
134134 } )
135135
136- // TODO: FIXME - windows currently throws 'nuxt-foo' is not recognized as an internal or external command, operable program or batch file.
136+ // TODO: on Windows tinyexec falls back to `cmd.exe`, which reports the missing binary itself rather than surfacing ENOENT
137137 it . skipIf ( isWindows ) ( 'throws error if wrong command is provided' , async ( ) => {
138138 const res = await x ( nuxi , [ 'foo' ] , {
139139 nodeOptions : { stdio : 'pipe' , cwd : fixtureDir } ,
@@ -142,6 +142,32 @@ describe('commands', () => {
142142 expect ( res . stderr ) . toBe ( '[error] Unknown command foo\n' )
143143 } )
144144
145+ it . skipIf ( isWindows ) ( 'rejects command names inherited from Object.prototype' , async ( ) => {
146+ const res = await x ( nuxi , [ 'toString' ] , {
147+ nodeOptions : { stdio : 'pipe' , cwd : fixtureDir } ,
148+ } )
149+ expect ( res . exitCode ) . toBe ( 1 )
150+ expect ( res . stderr ) . toBe ( '[error] Unknown command toString\n' )
151+ } )
152+
153+ it . skipIf ( isWindows ) ( 'forwards the exit status of a local command' , async ( ) => {
154+ const binDir = join ( fixtureDir , 'node_modules/.bin' )
155+ const bin = join ( binDir , 'nuxt-exit-test' )
156+ await mkdir ( binDir , { recursive : true } )
157+ await writeFile ( bin , '#!/bin/sh\nexit 42\n' )
158+ await chmod ( bin , 0o755 )
159+
160+ try {
161+ const res = await x ( nuxi , [ 'exit-test' ] , {
162+ nodeOptions : { stdio : 'pipe' , cwd : fixtureDir } ,
163+ } )
164+ expect ( res . exitCode ) . toBe ( 42 )
165+ }
166+ finally {
167+ await rm ( bin , { force : true } )
168+ }
169+ } )
170+
145171 const testsToRun = Object . entries ( tests ) . filter ( ( [ _ , value ] ) => value !== 'todo' )
146172 it . each ( testsToRun ) ( `%s` , { timeout : isWindows ? 200000 : 50000 } , ( _ , test ) => ( test as ( ) => Promise < void > ) ( ) )
147173
0 commit comments