36
36
`Couldn't find a 'package.json' file in '${ root } '. Are you in a project folder?`
37
37
) ;
38
38
}
39
+
39
40
const { source } = await inquirer . prompt ( {
40
41
type : 'input' ,
41
42
name : 'source' ,
@@ -44,16 +45,21 @@ yargs
44
45
validate : input => Boolean ( input ) ,
45
46
} ) ;
46
47
47
- if (
48
- ! (
49
- ( await fs . pathExists ( path . join ( root , source , 'index.js' ) ) ) ||
50
- ( await fs . pathExists ( path . join ( root , source , 'index.ts' ) ) ) ||
51
- ( await fs . pathExists ( path . join ( root , source , 'index.tsx' ) ) )
52
- )
53
- ) {
48
+ let entryFile ;
49
+
50
+ if ( await fs . pathExists ( path . join ( root , source , 'index.js' ) ) ) {
51
+ entryFile = 'index.js' ;
52
+ } else if ( await fs . pathExists ( path . join ( root , source , 'index.ts' ) ) ) {
53
+ entryFile = 'index.ts' ;
54
+ } else if ( await fs . pathExists ( path . join ( root , source , 'index.tsx' ) ) ) {
55
+ entryFile = 'index.tsx' ;
56
+ }
57
+
58
+ if ( ! entryFile ) {
54
59
logger . exit (
55
60
`Couldn't find a 'index.js'. 'index.ts' or 'index.tsx' file under '${ source } '. Please re-run the CLI after creating it.`
56
61
) ;
62
+ return ;
57
63
}
58
64
59
65
const pkg = JSON . parse ( await fs . readFile ( pak , 'utf-8' ) ) ;
88
94
const entries : { [ key : string ] : string } = {
89
95
main : target
90
96
? path . join ( output , target , 'index.js' )
91
- : path . join ( source , 'index.js' ) ,
92
- 'react-native' : path . join ( source , 'index.js' ) ,
97
+ : path . join ( source , entryFile ) ,
98
+ 'react-native' : path . join ( source , entryFile ) ,
93
99
} ;
94
100
95
101
if ( targets . includes ( 'module' ) ) {
0 commit comments