Skip to content
This repository has been archived by the owner on Jan 5, 2021. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into notices_report
Browse files Browse the repository at this point in the history
  • Loading branch information
jrichard committed Aug 23, 2017
2 parents 6616f66 + 19ebb0e commit 8d1adff
Showing 1 changed file with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,21 @@ class NpmBomTool extends BomTool {
@Autowired
NpmCliDependencyFinder cliDependencyFinder

@Autowired
YarnBomTool yarnBomTool

@Override
public BomToolType getBomToolType() {
BomToolType.NPM
}

@Override
public boolean isBomToolApplicable() {
if (yarnBomTool.isBomToolApplicable()) {
logger.debug("Not running npm bomtool because Yarn is applicable")
return false
}

boolean containsNodeModules = detectFileManager.containsAllFiles(sourcePath, NODE_MODULES)
boolean containsPackageJson = detectFileManager.containsAllFiles(sourcePath, PACKAGE_JSON)

Expand All @@ -65,24 +73,31 @@ class NpmBomTool extends BomTool {
}
}

containsNodeModules && npmExePath
boolean isApplicable = containsNodeModules && npmExePath
if (isApplicable) {
logger.debug("Npm version ${executableRunner.runExe(npmExePath, '-version').standardOutput}")
}

isApplicable
}

List<DetectCodeLocation> extractDetectCodeLocations() {
File npmLsOutputFile = detectFileManager.createFile(BomToolType.NPM, NpmBomTool.OUTPUT_FILE)
File npmLsErrorFile = detectFileManager.createFile(BomToolType.NPM, NpmBomTool.ERROR_FILE)
executableRunner.runExeToFile(npmExePath, npmLsOutputFile, npmLsErrorFile, 'ls', '-json')

if (npmLsErrorFile.length() == 0) {
if (logger.debugEnabled) {
def npmVersion = executableRunner.runExe(npmExePath, '-version')
if (npmLsOutputFile.length() > 0) {
if (npmLsErrorFile.length() > 0) {
logger.debug("Error when running npm ls -json command\n${npmLsErrorFile.text}")
}
def dependencyNode = cliDependencyFinder.generateDependencyNode(npmLsOutputFile)
def detectCodeLocation = new DetectCodeLocation(getBomToolType(), sourcePath, dependencyNode)

return [detectCodeLocation]
} else {
} else if (npmLsErrorFile.length() > 0) {
logger.error("Error when running npm ls -json command\n${npmLsErrorFile.text}")
} else {
logger.warn("Nothing returned from npm ls -json command");
}

[]
Expand Down

0 comments on commit 8d1adff

Please sign in to comment.