Skip to content

Commit a882392

Browse files
refactor: replace minimist on netlify-lambda.ts (#6265)
* refactor: replace minimist on netlify-lambda.ts replace minimist with commander on netlify-lambda.ts - replace minimist - update code accordingly * chore: remove dependency minimist - remove dependency minimist no longer needed --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 00ea7f1 commit a882392

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

package-lock.json

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@
150150
"lodash": "4.17.21",
151151
"log-symbols": "5.1.0",
152152
"log-update": "5.0.1",
153-
"minimist": "1.2.8",
154153
"multiparty": "4.2.3",
155154
"netlify": "13.1.11",
156155
"netlify-headers-parser": "7.1.2",

src/lib/functions/runtimes/js/builders/netlify-lambda.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { readFile } from 'fs/promises'
22
import { resolve } from 'path'
33

4-
import minimist from 'minimist'
4+
import { program } from 'commander'
55

66
// @ts-expect-error TS(7034) FIXME: Variable 'execa' implicitly has type 'any' in some... Remove this comment to see the full error message
77
import execa from '../../../../../utils/execa.js'
@@ -20,14 +20,18 @@ export const detectNetlifyLambda = async function ({ packageJson } = {}) {
2020

2121
for (const [key, script] of matchingScripts) {
2222
// E.g. ["netlify-lambda", "build", "functions/folder"]
23-
// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
24-
const match = minimist(script.split(' '), {
25-
// these are all valid options for netlify-lambda
26-
boolean: ['s', 'static'],
27-
string: ['c', 'config', 'p', 'port', 'b', 'babelrc', 't', 'timeout'],
28-
})
23+
// these are all valid options for netlify-lambda
24+
program
25+
.option('-s, --static')
26+
.option('-c, --config [file]')
27+
.option('-p, --port [number]')
28+
.option('-b, --babelrc [file]')
29+
.option('-t, --timeout [delay]')
30+
31+
program.parse((script as string).split(' ') ?? [])
32+
2933
// We are not interested in 'netlify-lambda' and 'build' commands
30-
const functionDirectories = match._.slice(2)
34+
const functionDirectories = program.args.filter((arg) => !['netlify-lambda', 'build'].includes(arg))
3135
if (functionDirectories.length === 1) {
3236
const srcFiles = [resolve(functionDirectories[0])]
3337

0 commit comments

Comments
 (0)