diff --git a/package-lock.json b/package-lock.json index ee3ede96d94..c85b0dd268b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -82,7 +82,6 @@ "lodash": "4.17.21", "log-symbols": "5.1.0", "log-update": "5.0.1", - "minimist": "1.2.8", "multiparty": "4.2.3", "netlify": "13.1.11", "netlify-headers-parser": "7.1.2", diff --git a/package.json b/package.json index 3fbe9eaffe0..2eb598444d7 100644 --- a/package.json +++ b/package.json @@ -150,7 +150,6 @@ "lodash": "4.17.21", "log-symbols": "5.1.0", "log-update": "5.0.1", - "minimist": "1.2.8", "multiparty": "4.2.3", "netlify": "13.1.11", "netlify-headers-parser": "7.1.2", diff --git a/src/lib/functions/runtimes/js/builders/netlify-lambda.ts b/src/lib/functions/runtimes/js/builders/netlify-lambda.ts index 4a03f93c7e2..db0634dd7de 100644 --- a/src/lib/functions/runtimes/js/builders/netlify-lambda.ts +++ b/src/lib/functions/runtimes/js/builders/netlify-lambda.ts @@ -1,7 +1,7 @@ import { readFile } from 'fs/promises' import { resolve } from 'path' -import minimist from 'minimist' +import { program } from 'commander' // @ts-expect-error TS(7034) FIXME: Variable 'execa' implicitly has type 'any' in some... Remove this comment to see the full error message import execa from '../../../../../utils/execa.js' @@ -20,14 +20,18 @@ export const detectNetlifyLambda = async function ({ packageJson } = {}) { for (const [key, script] of matchingScripts) { // E.g. ["netlify-lambda", "build", "functions/folder"] - // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. - const match = minimist(script.split(' '), { - // these are all valid options for netlify-lambda - boolean: ['s', 'static'], - string: ['c', 'config', 'p', 'port', 'b', 'babelrc', 't', 'timeout'], - }) + // these are all valid options for netlify-lambda + program + .option('-s, --static') + .option('-c, --config [file]') + .option('-p, --port [number]') + .option('-b, --babelrc [file]') + .option('-t, --timeout [delay]') + + program.parse((script as string).split(' ') ?? []) + // We are not interested in 'netlify-lambda' and 'build' commands - const functionDirectories = match._.slice(2) + const functionDirectories = program.args.filter((arg) => !['netlify-lambda', 'build'].includes(arg)) if (functionDirectories.length === 1) { const srcFiles = [resolve(functionDirectories[0])]