File tree Expand file tree Collapse file tree 2 files changed +23
-16
lines changed
packages/create-react-native-library/src Expand file tree Collapse file tree 2 files changed +23
-16
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { spawn } from './utils/spawn';
1616import { version } from '../package.json' ;
1717import { addCodegenBuildScript } from './utils/addCodegenBuildScript' ;
1818import { createInitialGitCommit } from './utils/initialCommit' ;
19+ import { assertNpx } from './utils/assert' ;
1920
2021const FALLBACK_BOB_VERSION = '0.29.0' ;
2122
@@ -342,22 +343,7 @@ async function create(_argv: yargs.Arguments<any>) {
342343 process . exit ( 1 ) ;
343344 }
344345
345- try {
346- await spawn ( 'npx' , [ '--help' ] ) ;
347- } catch ( error ) {
348- // @ts -expect-error: TS doesn't know about `code`
349- if ( error != null && error . code === 'ENOENT' ) {
350- console . log (
351- `Couldn't find ${ kleur . blue (
352- 'npx'
353- ) } ! Please install it by running ${ kleur . blue ( 'npm install -g npx' ) } `
354- ) ;
355-
356- process . exit ( 1 ) ;
357- } else {
358- throw error ;
359- }
360- }
346+ await assertNpx ( ) ;
361347
362348 let name , email ;
363349
Original file line number Diff line number Diff line change 1+ import kleur from 'kleur' ;
2+ import { spawn } from './spawn' ;
3+
4+ export async function assertNpx ( ) {
5+ try {
6+ await spawn ( 'npx' , [ '--help' ] ) ;
7+ } catch ( error ) {
8+ // @ts -expect-error: TS doesn't know about `code`
9+ if ( error != null && error . code === 'ENOENT' ) {
10+ console . log (
11+ `Couldn't find ${ kleur . blue (
12+ 'npx'
13+ ) } ! Please install it by running ${ kleur . blue ( 'npm install -g npx' ) } `
14+ ) ;
15+
16+ process . exit ( 1 ) ;
17+ } else {
18+ throw error ;
19+ }
20+ }
21+ }
You can’t perform that action at this time.
0 commit comments