@@ -18,49 +18,27 @@ const certify = () =>
1818( async ( ) => {
1919 // Parse arguments from the command line
2020 program
21- . arguments ( '[root] [fallback] [port]' )
21+ . arguments ( '[root]' )
22+ . option ( '-f, --fallback <fallback>' , 'fallback file' , 'index.html' )
23+ . option ( '-p, --port <port>' , 'port to use' , '8080' )
2224 . option ( '-r, --reload' , 'reload on file change' )
2325 . option ( '-m, --module' , 'serve javascript modules' )
2426 . option ( '-s, --static' , 'serve static files' )
2527 . option ( '--secure' , 'use https' )
2628 . option ( '-b, --browse' , 'open browser on start' )
27- . option ( '--localhost-only ' , 'only serve on localhost ' )
28- . option ( '--no- dir-listing' , 'disable directory listing' )
29+ . option ( '--host <host> ' , 'host to listen on ' )
30+ . option ( '--dir-listing' , 'enable directory listing' )
2931 . option ( '--silent' , 'disable console output' )
30- . option ( '--editor' , 'open code editor' )
3132 . parse ( process . argv ) ;
3233
3334 const opts = program . opts ( ) ;
3435 const argsRoot = program . args [ 0 ] ;
35- const fallback = program . args [ 1 ] ;
36- const argsPort = program . args [ 2 ] ;
36+ const fallback = opts . fallback ;
37+ const argsPort = opts . port ;
3738
38- // const args = process.argv.slice(2).filter((x) => !~x.indexOf('--'));
3939 const admin = process . getuid && process . getuid ( ) === 0 ;
4040 let credentials ;
4141
42- // if (args[0] && args[0].startsWith('gh:')) {
43- // const repo = args[0].replace('gh:', '');
44- // const dest = repo.split('/')[1];
45- // if (!fs.existsSync(dest)) {
46- // try {
47- // require('child_process').execSync(`git clone https://github.com/${repo}`, { stdio: 'ignore' });
48- // } catch (e) {
49- // console.log(`\n ⚠️ Could not clone from https://github.com/${repo}\n`);
50- // process.exit();
51- // }
52- // }
53- // args[0] = dest;
54- // }
55-
56- if ( opts . editor ) {
57- try {
58- require ( 'child_process' ) . execSync ( `code ${ argsRoot || '.' } ` ) ;
59- } catch ( e ) {
60- console . log ( `\n ⚠️ Could not open code editor for ${ argsRoot || '.' } ` ) ;
61- }
62- }
63-
6442 // Generate ssl certificates
6543
6644 if ( opts . secure ) {
@@ -83,11 +61,11 @@ const certify = () =>
8361 root : argsRoot ,
8462 fallback,
8563 port : argsPort ,
86- reload : ! ! opts . reload ,
87- module : ! ! opts . module ,
88- static : ! ! opts . static ,
89- host : ! ! opts . localhostOnly ? '127.0.0.1' : undefined ,
90- noDirListing : ! ! opts . noDirListing ,
64+ reload : opts . reload ,
65+ module : opts . module ,
66+ static : opts . static ,
67+ host : opts . host ,
68+ noDirListing : ! opts . dirListing ,
9169 credentials,
9270 } ) ;
9371
0 commit comments