Skip to content

Commit f2075b8

Browse files
renovate[bot]danez
andauthored
fix(deps): update dependency commander to v9 (#574)
* fix(deps): update dependency commander to v9 * fix: commander usage Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Daniel Tschinder <231804+danez@users.noreply.github.com>
1 parent 0edd46f commit f2075b8

File tree

3 files changed

+30
-978
lines changed

3 files changed

+30
-978
lines changed

bin/cmd.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var serve = require('../lib/serve');
1515
var install = require('../lib/install');
1616

1717
program.version(pkg.version);
18+
program.showHelpAfterError();
1819

1920
const stringBooleanToBoolean = (val) => {
2021
console.log({ val });
@@ -42,24 +43,26 @@ program
4243
program
4344
.command('serve <dir>')
4445
.description('serve and watch functions')
45-
.action(function (cmd) {
46+
.action(function (dir) {
4647
console.log('netlify-lambda: Starting server');
47-
var static = Boolean(program.static);
48+
var opts = program.opts();
49+
var static = Boolean(opts.static);
4850
var server;
4951
var startServer = async function () {
5052
server = await serve.listen(
51-
program.port || 9000,
53+
opts.port || 9000,
5254
static,
53-
Number(program.timeout) || 10,
55+
Number(opts.timeout) || 10,
5456
);
5557
};
5658
if (static) {
5759
startServer();
5860
return; // early terminate, don't build
5961
}
60-
const { config: userWebpackConfig, babelrc: useBabelrc = true } = program;
62+
const { config: userWebpackConfig, babelrc: useBabelrc = true } =
63+
program.opts();
6164
build.watch(
62-
cmd,
65+
dir,
6366
{ userWebpackConfig, useBabelrc },
6467
async function (err, stats) {
6568
if (err) {
@@ -80,12 +83,13 @@ program
8083
program
8184
.command('build <dir>')
8285
.description('build functions')
83-
.action(function (cmd) {
86+
.action(function (dir) {
8487
console.log('netlify-lambda: Building functions');
8588

86-
const { config: userWebpackConfig, babelrc: useBabelrc = true } = program;
89+
const { config: userWebpackConfig, babelrc: useBabelrc = true } =
90+
program.opts();
8791
build
88-
.run(cmd, { userWebpackConfig, useBabelrc })
92+
.run(dir, { userWebpackConfig, useBabelrc })
8993
.then(function (stats) {
9094
console.log(stats.toString(stats.compilation.options.stats));
9195
})
@@ -98,9 +102,9 @@ program
98102
program
99103
.command('install [dir]')
100104
.description('install functions')
101-
.action(function (cmd) {
105+
.action(function (dir) {
102106
console.log('netlify-lambda: installing function dependencies');
103-
install.run(cmd).catch(function (err) {
107+
install.run(dir).catch(function (err) {
104108
console.error(err);
105109
process.exit(1);
106110
});

0 commit comments

Comments
 (0)