From bfdb84813260f0edbf759f2fde1e8c816c1478b8 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 1 Mar 2022 21:38:48 -0800 Subject: [PATCH] [Fix] reject invalid `only` values --- .eslintrc | 1 + getLockfile.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.eslintrc b/.eslintrc index 5597fdc..44d150f 100644 --- a/.eslintrc +++ b/.eslintrc @@ -7,6 +7,7 @@ "consistent-return": 1, "func-name-matching": 0, "max-nested-callbacks": 0, + "max-lines-per-function": 0, "sort-keys": 0, }, } diff --git a/getLockfile.js b/getLockfile.js index ca351bb..423cd43 100644 --- a/getLockfile.js +++ b/getLockfile.js @@ -23,6 +23,9 @@ module.exports = function getLockfile(packageFile, date, { if (typeof date !== 'undefined' && !new Date(date).getTime()) { return Promise.reject(colors.red(`\`date\` must be a valid Date format if provided; got ${inspect(date)}`)); } + if (only && only !== 'prod' && only !== 'production') { + return Promise.reject(colors.red('`only`, when provided, must be "prod" or "production"')); + } const tmpDirP = getProjectTempDir({ npmNeeded, logger }); const npmRC = path.join(path.dirname(packageFile), '.npmrc'); const copyPkg = tmpDirP.then((tmpDir) => {