Skip to content

Commit f3275cb

Browse files
committed
feat(node): Allow a custom fallback when filtering definition files
Also remove a comment that is now better explained by the code. Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent c18a5fd commit f3275cb

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

plugins/package-managers/node/src/main/kotlin/NodePackageManagerDetection.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,24 @@ internal class NodePackageManagerDetection(private val definitionFiles: Collecti
101101
}
102102

103103
/**
104-
* Return those [definitionFiles] that define root projects for the given [manager].
104+
* Return those [definitionFiles] that define root projects for the given [manager], or that are managed by
105+
* [fallbackType] as a fallback.
105106
*/
106-
fun filterApplicable(manager: NodePackageManagerType): List<File> =
107+
fun filterApplicable(
108+
manager: NodePackageManagerType,
109+
fallbackType: NodePackageManagerType = NodePackageManagerType.NPM
110+
): List<File> =
107111
definitionFiles.filter { file ->
108112
val projectDir = file.parentFile
109113
val managersFromFiles = projectDirManagers[projectDir].orEmpty()
110114

111115
isApplicable(manager, file) ?: run {
112-
// Looking at the workspaces did not bring any clarity, so assume the package manager is NPM.
113116
logger.warn {
114-
"Any of $managersFromFiles could be the package manager for '$file'. Assuming it is an NPM project."
117+
"Any of $managersFromFiles could be the package manager for '$file'. " +
118+
"Assuming it is a(n) $fallbackType project."
115119
}
116120

117-
manager == NodePackageManagerType.NPM
121+
manager == fallbackType
118122
}
119123
}
120124
}

0 commit comments

Comments
 (0)