Skip to content

Commit

Permalink
refactor(node): Remove a dependency on Npm
Browse files Browse the repository at this point in the history
Use an own logger instead of the one from `Npm`.

Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed Nov 6, 2024
1 parent 009b8fd commit d48900f
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
package org.ossreviewtoolkit.plugins.packagemanagers.node.utils

import java.io.File
import java.lang.invoke.MethodHandles

import org.apache.logging.log4j.kotlin.logger
import org.apache.logging.log4j.kotlin.loggerOf

import org.ossreviewtoolkit.analyzer.PackageManager.Companion.getFallbackProjectName
import org.ossreviewtoolkit.analyzer.PackageManager.Companion.processPackageVcs
Expand All @@ -37,7 +38,6 @@ import org.ossreviewtoolkit.model.RemoteArtifact
import org.ossreviewtoolkit.model.VcsInfo
import org.ossreviewtoolkit.model.VcsType
import org.ossreviewtoolkit.plugins.packagemanagers.node.PackageJson
import org.ossreviewtoolkit.plugins.packagemanagers.node.npm.Npm
import org.ossreviewtoolkit.plugins.packagemanagers.node.parsePackageJson
import org.ossreviewtoolkit.utils.common.realFile
import org.ossreviewtoolkit.utils.common.toUri
Expand Down Expand Up @@ -247,8 +247,10 @@ internal fun parsePackage(
return module
}

private val logger = loggerOf(MethodHandles.lookup().lookupClass())

internal fun parseProject(packageJsonFile: File, analysisRoot: File, managerName: String): Project {
Npm.logger.debug { "Parsing project info from '$packageJsonFile'." }
logger.debug { "Parsing project info from '$packageJsonFile'." }

val packageJson = parsePackageJson(packageJsonFile)

Expand All @@ -257,13 +259,13 @@ internal fun parseProject(packageJsonFile: File, analysisRoot: File, managerName

val projectName = name.ifBlank {
getFallbackProjectName(analysisRoot, packageJsonFile).also {
Npm.logger.warn { "'$packageJsonFile' does not define a name, falling back to '$it'." }
logger.warn { "'$packageJsonFile' does not define a name, falling back to '$it'." }
}
}

val version = packageJson.version.orEmpty()
if (version.isBlank()) {
Npm.logger.warn { "'$packageJsonFile' does not define a version." }
logger.warn { "'$packageJsonFile' does not define a version." }
}

val declaredLicenses = packageJson.licenses.mapNpmLicenses()
Expand Down

0 comments on commit d48900f

Please sign in to comment.