@@ -15,6 +15,8 @@ const { name } = require('../package.json');
15
15
const root = process . cwd ( ) ;
16
16
const explorer = cosmiconfig ( name ) ;
17
17
18
+ const FLOW_PRGAMA_REGEX = / \* ? \s * @ ( f l o w ) \b / m;
19
+
18
20
yargs
19
21
. command ( 'init' , 'configure the package to use bob' , { } , async ( ) => {
20
22
const pak = path . join ( root , 'package.json' ) ;
64
66
}
65
67
66
68
const pkg = JSON . parse ( await fs . readFile ( pak , 'utf-8' ) ) ;
67
- const { output , targets , flow } = await inquirer . prompt ( [
69
+ const questions : inquirer . Question [ ] = [
68
70
{
69
71
type : 'input' ,
70
72
name : 'output' ,
@@ -79,13 +81,23 @@ yargs
79
81
choices : [ 'commonjs' , 'module' , 'typescript' ] ,
80
82
validate : input => Boolean ( input . length ) ,
81
83
} ,
82
- {
84
+ ] ;
85
+
86
+ if (
87
+ entryFile . endsWith ( '.js' ) &&
88
+ FLOW_PRGAMA_REGEX . test (
89
+ await fs . readFile ( path . join ( root , source , entryFile ) , 'utf-8' )
90
+ )
91
+ ) {
92
+ questions . push ( {
83
93
type : 'confirm' ,
84
94
name : 'flow' ,
85
95
message : 'Do you want to publish definitions for flow?' ,
86
96
default : Object . keys ( pkg . devDependencies || { } ) . includes ( 'flow-bin' ) ,
87
- } ,
88
- ] ) ;
97
+ } ) ;
98
+ }
99
+
100
+ const { output, targets, flow } = await inquirer . prompt ( questions ) ;
89
101
90
102
const target =
91
103
targets [ 0 ] === 'commonjs' || targets [ 0 ] === 'module'
0 commit comments