1
- import arg from "arg" ;
2
1
import * as inquirer from "inquirer" ;
3
2
import simpleGit from "simple-git/promise" ;
4
3
import * as fs from "fs" ;
5
4
import * as T from "../typings/tutorial" ;
6
5
import build , { BuildOptions } from "./build" ;
7
6
import create from "./create" ;
8
7
8
+ // import not working
9
+ const arg = require ( "arg" ) ;
10
+
9
11
type Q = inquirer . Question < any > & { choices ?: string [ ] } ;
10
12
11
13
type ParsedArgs = {
@@ -49,18 +51,21 @@ function parseArgumentsIntoOptions(rawArgs: string[]): ParsedArgs {
49
51
argv : rawArgs . slice ( 2 ) ,
50
52
}
51
53
) ;
54
+ console . log ( args ) ;
52
55
return {
53
56
command : args [ "_" ] [ 0 ] ,
54
57
git : args [ "--git" ] ,
55
58
dir : args [ "--dir" ] ,
56
59
codeBranch : args [ "--code" ] ,
57
60
setupBranch : args [ "--setup" ] ,
58
- output : args [ "--output" ] ,
61
+ output : args [ "--output" ] || "./config.json" ,
59
62
help : args [ "--help" ] || false ,
60
63
} ;
61
64
}
62
65
63
- async function promptForMissingOptions ( options : ParsedArgs ) : Promise < Options > {
66
+ export async function promptForMissingOptions (
67
+ options : ParsedArgs
68
+ ) : Promise < Options > {
64
69
const questions : Q [ ] = [ ] ;
65
70
66
71
// if no git remote addres is provided, assume current folder
@@ -147,7 +152,7 @@ async function promptForMissingOptions(options: ParsedArgs): Promise<Options> {
147
152
} ;
148
153
}
149
154
150
- export async function cli ( args : string [ ] ) {
155
+ export async function cli ( args : string [ ] ) : Promise < void > {
151
156
let parsedArgs : ParsedArgs = parseArgumentsIntoOptions ( args ) ;
152
157
153
158
// If help called just print the help text and exit
@@ -174,11 +179,12 @@ export async function cli(args: string[]) {
174
179
console . log ( JSON . stringify ( tutorial , null , 2 ) ) ;
175
180
}
176
181
}
177
- return ;
182
+ break ;
178
183
179
184
case "create" :
185
+ console . log ( "here" ) ;
180
186
create ( process . cwd ( ) ) ;
181
- return ;
187
+ break ;
182
188
}
183
189
}
184
190
}
0 commit comments