@@ -140,15 +140,6 @@ const itWithMockNpmRegistry = it.extend<{ registry: { address: string; cwd: stri
140
140
} ,
141
141
} )
142
142
143
- const doesPackageManagerExist = ( packageManager : string ) : boolean => {
144
- try {
145
- execSync ( `${ packageManager } --version` )
146
- return true
147
- } catch {
148
- return false
149
- }
150
- }
151
-
152
143
const tests : [ packageManager : string , config : { install : [ cmd : string , args : string [ ] ] ; lockfile : string } ] [ ] = [
153
144
[
154
145
'npm' ,
@@ -174,29 +165,26 @@ const tests: [packageManager: string, config: { install: [cmd: string, args: str
174
165
]
175
166
176
167
describe . each ( tests ) ( '%s → installs the cli and runs the help command without error' , ( packageManager , config ) => {
177
- itWithMockNpmRegistry . runIf ( doesPackageManagerExist ( packageManager ) ) (
178
- 'installs the cli and runs the help command without error' ,
179
- async ( { registry } ) => {
180
- const cwd = registry . cwd
181
- await execa ( ...config . install , {
182
- cwd,
183
- env : { npm_config_registry : registry . address } ,
184
- stdio : debug . enabled ? 'inherit' : 'ignore' ,
185
- } )
168
+ itWithMockNpmRegistry ( 'installs the cli and runs the help command without error' , async ( { registry } ) => {
169
+ const cwd = registry . cwd
170
+ await execa ( ...config . install , {
171
+ cwd,
172
+ env : { npm_config_registry : registry . address } ,
173
+ stdio : debug . enabled ? 'inherit' : 'ignore' ,
174
+ } )
186
175
187
- expect (
188
- existsSync ( path . join ( cwd , config . lockfile ) ) ,
189
- `Generated lock file ${ config . lockfile } does not exist in ${ cwd } ` ,
190
- ) . toBe ( true )
176
+ expect (
177
+ existsSync ( path . join ( cwd , config . lockfile ) ) ,
178
+ `Generated lock file ${ config . lockfile } does not exist in ${ cwd } ` ,
179
+ ) . toBe ( true )
191
180
192
- const binary = path . resolve ( path . join ( cwd , `./node_modules/.bin/netlify${ platform ( ) === 'win32' ? '.cmd' : '' } ` ) )
193
- const { stdout } = await execa ( binary , [ 'help' ] , { cwd } )
181
+ const binary = path . resolve ( path . join ( cwd , `./node_modules/.bin/netlify${ platform ( ) === 'win32' ? '.cmd' : '' } ` ) )
182
+ const { stdout } = await execa ( binary , [ 'help' ] , { cwd } )
194
183
195
- expect ( stdout . trim ( ) , `Help command does not start with 'VERSION':\n\n${ stdout } ` ) . toMatch ( / ^ V E R S I O N / )
196
- expect ( stdout , `Help command does not include 'netlify-cli/${ pkg . version } ':\n\n${ stdout } ` ) . toContain (
197
- `netlify-cli/${ pkg . version } ` ,
198
- )
199
- expect ( stdout , `Help command does not include '$ netlify [COMMAND]':\n\n${ stdout } ` ) . toMatch ( '$ netlify [COMMAND]' )
200
- } ,
201
- )
184
+ expect ( stdout . trim ( ) , `Help command does not start with 'VERSION':\n\n${ stdout } ` ) . toMatch ( / ^ V E R S I O N / )
185
+ expect ( stdout , `Help command does not include 'netlify-cli/${ pkg . version } ':\n\n${ stdout } ` ) . toContain (
186
+ `netlify-cli/${ pkg . version } ` ,
187
+ )
188
+ expect ( stdout , `Help command does not include '$ netlify [COMMAND]':\n\n${ stdout } ` ) . toMatch ( '$ netlify [COMMAND]' )
189
+ } )
202
190
} )
0 commit comments