@@ -64,11 +64,11 @@ function runFromCli() {
6464 }
6565
6666 if ( input . length ) {
67- return handleNoCommand ( argv , input ) ;
67+ return handleNoCommand ( argv , input , yargs ) ;
6868 }
6969
7070 if ( existsSync ( "index.html" ) ) {
71- return handleNoCommand ( argv , [ "." ] ) ;
71+ return handleNoCommand ( argv , [ "." ] , yargs ) ;
7272 }
7373
7474 yargs . showHelp ( ) ;
@@ -91,8 +91,9 @@ function runFromCli() {
9191 * @param input
9292 * @returns {any }
9393 */
94- function handleNoCommand ( argv , input ) {
94+ function handleNoCommand ( argv , input , yargs ) {
9595
96+ const processed = processStart ( yargs ) ;
9697 const paths = input . map ( path => {
9798 const resolved = resolve ( path ) ;
9899 const isUrl = / ^ h t t p s ? : \/ \/ / . test ( path ) ;
@@ -129,22 +130,23 @@ function handleNoCommand(argv, input) {
129130 if ( urls . length ) {
130131 const proxy = urls [ 0 ] ;
131132 const config = {
132- ...argv ,
133+ ...processed ,
133134 proxy,
134135 serveStatic : serveStaticPaths
135136 } ;
136- return handleCli ( { cli : { flags : config , input : [ "start" ] } } ) ;
137+ return handleIncoming ( 'start' , yargs . reset ( ) ) ;
137138 }
138139
139140 /**
140141 * if NO urls were given switch directly to server mode
141142 * @type {{server: {baseDir: any}} }
142143 */
143144 const config = {
144- ...argv ,
145+ ...processed ,
145146 server : { baseDir : serveStaticPaths }
146147 } ;
147- handleCli ( { cli : { flags : config , input : [ "start" ] } } ) ;
148+
149+ return handleCli ( { cli : { flags : config , input : [ "start" ] } } ) ;
148150}
149151
150152/**
@@ -158,22 +160,25 @@ function handleCli(opts) {
158160
159161export default handleCli ;
160162
163+ function processStart ( yargs ) {
164+ return yargs
165+ . usage ( "Usage: $0 start [options]" )
166+ . options ( startOpts )
167+ . example (
168+ "$0 start -s app" ,
169+ "- Use the App directory to serve files"
170+ )
171+ . example ( "$0 start -p www.bbc.co.uk" , "- Proxy an existing website" )
172+ . help ( ) . argv ;
173+ }
161174/**
162175 * @param {string } command
163176 * @param {object } yargs
164177 */
165178function handleIncoming ( command , yargs ) {
166179 let out ;
167180 if ( command === "start" ) {
168- out = yargs
169- . usage ( "Usage: $0 start [options]" )
170- . options ( startOpts )
171- . example (
172- "$0 start -s app" ,
173- "- Use the App directory to serve files"
174- )
175- . example ( "$0 start -p www.bbc.co.uk" , "- Proxy an existing website" )
176- . help ( ) . argv ;
181+ out = processStart ( yargs ) ;
177182 }
178183 if ( command === "init" ) {
179184 out = yargs
0 commit comments