@@ -37,13 +37,18 @@ if (!module.parent) {
37
37
runFromCli ( ) ;
38
38
}
39
39
40
+ function freshYargs ( ) {
41
+ return require ( "yargs" ) ( process . argv . slice ( 2 ) ) ;
42
+ }
43
+
40
44
function runFromCli ( ) {
41
- const yargs = require ( "yargs" )
45
+ const yargs = freshYargs ( )
42
46
. command ( "start" , "Start the server" )
43
47
. command ( "init" , "Create a configuration file" )
44
48
. command ( "reload" , "Send a reload event over HTTP protocol" )
45
49
. command ( "recipe" , "Generate the files for a recipe" )
46
50
. version ( pkg . version )
51
+ . help ( false )
47
52
. epilogue (
48
53
[
49
54
"For help running a certain command, type <command> --help" ,
@@ -69,15 +74,15 @@ function runFromCli() {
69
74
const valid = [ "start" , "init" , "reload" , "recipe" ] ;
70
75
71
76
if ( valid . indexOf ( command ) > - 1 ) {
72
- return handleIncoming ( command , yargs . reset ( ) ) ;
77
+ return handleIncoming ( command , freshYargs ( ) ) ;
73
78
}
74
79
75
80
if ( input . length ) {
76
- return handleNoCommand ( argv , input , yargs ) ;
81
+ return handleNoCommand ( argv , input , freshYargs ( ) ) ;
77
82
}
78
83
79
84
if ( existsSync ( "index.html" ) ) {
80
- return handleNoCommand ( argv , [ "." ] , yargs ) ;
85
+ return handleNoCommand ( argv , [ "." ] , freshYargs ( ) ) ;
81
86
}
82
87
83
88
yargs . showHelp ( ) ;
@@ -179,7 +184,7 @@ function processStart(yargs) {
179
184
. example ( "$0 start -s app" , "- Use the App directory to serve files" )
180
185
. example ( "$0 start -p www.bbc.co.uk" , "- Proxy an existing website" )
181
186
. default ( "cwd" , ( ) => process . cwd ( ) )
182
- . help ( ) . argv ;
187
+ . argv ;
183
188
}
184
189
185
190
/**
@@ -206,7 +211,7 @@ function handleIncoming(command, yargs) {
206
211
. example ( "$0 reload" )
207
212
. example ( "$0 reload --port 4000" )
208
213
. default ( "cwd" , ( ) => process . cwd ( ) )
209
- . help ( ) . argv ;
214
+ . argv ;
210
215
}
211
216
if ( command === "recipe" ) {
212
217
out = yargs
@@ -215,7 +220,7 @@ function handleIncoming(command, yargs) {
215
220
. example ( "$0 recipe ls" , "list the recipes" )
216
221
. example ( "$0 recipe gulp.sass" , "use the gulp.sass recipe" )
217
222
. default ( "cwd" , ( ) => process . cwd ( ) )
218
- . help ( ) . argv ;
223
+ . argv ;
219
224
}
220
225
221
226
if ( out . help ) {
0 commit comments