Skip to content

Commit

Permalink
chore(node): Rename the typealias to get package details
Browse files Browse the repository at this point in the history
Make more clear that this is about *getting* package details, and use
only "Fun" to resemble the corresponding Kotlin keyword.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Jan 14, 2025
1 parent 1d9f415 commit 95a192f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions plugins/package-managers/node/src/main/kotlin/NpmSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ internal fun parseVcsInfo(packageJson: PackageJson): VcsInfo {
)
}

typealias PackageDetailsFunction = (packageName: String) -> PackageJson?
typealias GetPackageDetailsFun = (packageName: String) -> PackageJson?

/**
* Construct a [Package] by parsing its _package.json_ file and - if applicable - querying additional
* content via the `npm view` command. The result is a [Pair] with the raw identifier and the new package.
*/
internal fun parsePackage(packageJsonFile: File, getPackageDetails: PackageDetailsFunction): Package {
internal fun parsePackage(packageJsonFile: File, getPackageDetails: GetPackageDetailsFun): Package {
val packageJson = parsePackageJson(packageJsonFile)

// The "name" and "version" fields are only required if the package is going to be published, otherwise they are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import org.ossreviewtoolkit.model.Issue
import org.ossreviewtoolkit.model.Package
import org.ossreviewtoolkit.model.PackageLinkage
import org.ossreviewtoolkit.model.utils.DependencyHandler
import org.ossreviewtoolkit.plugins.packagemanagers.node.GetPackageDetailsFun
import org.ossreviewtoolkit.plugins.packagemanagers.node.NodePackageManager
import org.ossreviewtoolkit.plugins.packagemanagers.node.PackageDetailsFunction
import org.ossreviewtoolkit.plugins.packagemanagers.node.PackageJson
import org.ossreviewtoolkit.plugins.packagemanagers.node.parsePackage
import org.ossreviewtoolkit.plugins.packagemanagers.node.parsePackageJson
Expand All @@ -36,7 +36,7 @@ import org.ossreviewtoolkit.utils.common.realFile

internal class NpmDependencyHandler(
private val projectType: String,
private val getPackageDetails: PackageDetailsFunction
private val getPackageDetails: GetPackageDetailsFun
) : DependencyHandler<ModuleInfo> {
private val packageJsonCache = mutableMapOf<File, PackageJson>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import org.ossreviewtoolkit.model.Issue
import org.ossreviewtoolkit.model.Package
import org.ossreviewtoolkit.model.PackageLinkage
import org.ossreviewtoolkit.model.utils.DependencyHandler
import org.ossreviewtoolkit.plugins.packagemanagers.node.GetPackageDetailsFun
import org.ossreviewtoolkit.plugins.packagemanagers.node.NodePackageManager
import org.ossreviewtoolkit.plugins.packagemanagers.node.PackageDetailsFunction
import org.ossreviewtoolkit.plugins.packagemanagers.node.PackageJson
import org.ossreviewtoolkit.plugins.packagemanagers.node.parsePackage
import org.ossreviewtoolkit.plugins.packagemanagers.node.parsePackageJson
Expand All @@ -36,7 +36,7 @@ import org.ossreviewtoolkit.utils.common.realFile

internal class PnpmDependencyHandler(
private val projectType: String,
private val getPackageDetails: PackageDetailsFunction
private val getPackageDetails: GetPackageDetailsFun
) : DependencyHandler<Dependency> {
private val workspaceModuleDirs = mutableSetOf<File>()
private val packageJsonCache = mutableMapOf<File, PackageJson>()
Expand Down

0 comments on commit 95a192f

Please sign in to comment.