From 44e32fa414b0525ab8c01293fd917783e073c361 Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Tue, 15 Aug 2023 17:20:55 +0100 Subject: [PATCH] use --no-package-lock in npm after npm 4 --- lib/dependency-manager-adapters/npm.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/dependency-manager-adapters/npm.js b/lib/dependency-manager-adapters/npm.js index b4b7a691..f4140f25 100644 --- a/lib/dependency-manager-adapters/npm.js +++ b/lib/dependency-manager-adapters/npm.js @@ -133,8 +133,14 @@ module.exports = CoreObject.extend({ if (mgrOptions.indexOf('--ignore-engines') === -1) { mgrOptions = mgrOptions.concat(['--ignore-engines']); } - } else if (mgrOptions.indexOf('--no-shrinkwrap') === -1) { - mgrOptions = mgrOptions.concat(['--no-shrinkwrap']); + } else if (mgrOptions.indexOf('--no-package-lock') === -1) { + let res = await this.run('npm', ['--version'], { cwd: this.cwd, stdio: 'pipe' }); + let version = res.stdout; + if (version.match(/^4./)) { + mgrOptions = mgrOptions.concat(['--no-shrinkwrap']); + } else { + mgrOptions = mgrOptions.concat(['--no-package-lock']); + } } }