@@ -15,6 +15,7 @@ var serve = require('../lib/serve');
15
15
var install = require ( '../lib/install' ) ;
16
16
17
17
program . version ( pkg . version ) ;
18
+ program . showHelpAfterError ( ) ;
18
19
19
20
const stringBooleanToBoolean = ( val ) => {
20
21
console . log ( { val } ) ;
@@ -42,24 +43,26 @@ program
42
43
program
43
44
. command ( 'serve <dir>' )
44
45
. description ( 'serve and watch functions' )
45
- . action ( function ( cmd ) {
46
+ . action ( function ( dir ) {
46
47
console . log ( 'netlify-lambda: Starting server' ) ;
47
- var static = Boolean ( program . static ) ;
48
+ var opts = program . opts ( ) ;
49
+ var static = Boolean ( opts . static ) ;
48
50
var server ;
49
51
var startServer = async function ( ) {
50
52
server = await serve . listen (
51
- program . port || 9000 ,
53
+ opts . port || 9000 ,
52
54
static ,
53
- Number ( program . timeout ) || 10 ,
55
+ Number ( opts . timeout ) || 10 ,
54
56
) ;
55
57
} ;
56
58
if ( static ) {
57
59
startServer ( ) ;
58
60
return ; // early terminate, don't build
59
61
}
60
- const { config : userWebpackConfig , babelrc : useBabelrc = true } = program ;
62
+ const { config : userWebpackConfig , babelrc : useBabelrc = true } =
63
+ program . opts ( ) ;
61
64
build . watch (
62
- cmd ,
65
+ dir ,
63
66
{ userWebpackConfig, useBabelrc } ,
64
67
async function ( err , stats ) {
65
68
if ( err ) {
@@ -80,12 +83,13 @@ program
80
83
program
81
84
. command ( 'build <dir>' )
82
85
. description ( 'build functions' )
83
- . action ( function ( cmd ) {
86
+ . action ( function ( dir ) {
84
87
console . log ( 'netlify-lambda: Building functions' ) ;
85
88
86
- const { config : userWebpackConfig , babelrc : useBabelrc = true } = program ;
89
+ const { config : userWebpackConfig , babelrc : useBabelrc = true } =
90
+ program . opts ( ) ;
87
91
build
88
- . run ( cmd , { userWebpackConfig, useBabelrc } )
92
+ . run ( dir , { userWebpackConfig, useBabelrc } )
89
93
. then ( function ( stats ) {
90
94
console . log ( stats . toString ( stats . compilation . options . stats ) ) ;
91
95
} )
@@ -98,9 +102,9 @@ program
98
102
program
99
103
. command ( 'install [dir]' )
100
104
. description ( 'install functions' )
101
- . action ( function ( cmd ) {
105
+ . action ( function ( dir ) {
102
106
console . log ( 'netlify-lambda: installing function dependencies' ) ;
103
- install . run ( cmd ) . catch ( function ( err ) {
107
+ install . run ( dir ) . catch ( function ( err ) {
104
108
console . error ( err ) ;
105
109
process . exit ( 1 ) ;
106
110
} ) ;
0 commit comments