@contrast/library-analysis
Advanced tools
Comparing version 1.12.1 to 1.13.0
@@ -20,3 +20,3 @@ /* | ||
const VERSION_REGEX = /^npm@(\S+)\s+(\S+[\s\S]*)$/m; | ||
const VERSION_REGEX = /^npm@(\S+)\s+(\S+)$/m; | ||
const isWin32 = process.platform === 'win32'; | ||
@@ -41,3 +41,2 @@ | ||
*/ | ||
// eslint-disable-next-line complexity | ||
module.exports = async function listInstalled(cwd, logger, npmVersionRange) { | ||
@@ -64,13 +63,8 @@ const execFileOpts = { | ||
const [, version, location] = stdout.match(VERSION_REGEX) || []; | ||
if (!version) | ||
throw new Error( | ||
"Unable to locate `npm`. `npm` is required for your application's libraries to be reported to Contrast for analysis. Please enable debug level logs for more information." | ||
); | ||
if (!version) { | ||
throw new Error("Unable to locate `npm`. `npm` is required for your application's libraries to be reported to Contrast for analysis. Please enable debug or trace level logs for more information."); | ||
} | ||
logger.debug('using npm version %s at %s', version, location); | ||
const lsArgs = ['ls', '--json', '--long']; | ||
// This will be needs to be updated once node 14 is no longer LTS | ||
if (semver.gte(version, '8.0.0')) lsArgs.push('--all'); | ||
if (!semver.satisfies(version, npmVersionRange)) | ||
if (!semver.satisfies(version, npmVersionRange)) { | ||
logger.warn( | ||
@@ -82,3 +76,8 @@ 'The installed version of npm (%s at %s) can cause unexpected behavior. Please install a version that satisfies %s', | ||
); | ||
} | ||
const lsArgs = ['ls', '--json', '--long']; | ||
// This will be needs to be updated once node 14 is no longer LTS | ||
if (semver.gte(version, '8.0.0')) lsArgs.push('--all'); | ||
try { | ||
@@ -96,6 +95,4 @@ const result = await execFile('npm', lsArgs, execFileOpts); | ||
logger.trace({ err }, 'parsing the output of `npm ls` failed'); | ||
throw new Error( | ||
'`npm ls` failed to provide a list of installed dependencies. Please enable trace level logs for more information.' | ||
); | ||
throw new Error('`npm ls` failed to provide a list of installed dependencies. Please enable trace level logs for more information.'); | ||
} | ||
}; |
{ | ||
"name": "@contrast/library-analysis", | ||
"version": "1.12.1", | ||
"version": "1.13.0", | ||
"description": "Handles library reporting and library usage analysis", | ||
@@ -5,0 +5,0 @@ "license": "SEE LICENSE IN LICENSE", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16804
424