Skip to content

Commit

Permalink
Merge pull request #12 from BartBM/master
Browse files Browse the repository at this point in the history
Add Aurelia detection to package.json field devDependencies
  • Loading branch information
CollinHerber authored Sep 5, 2024
2 parents 5b9a3a7 + 98c62e8 commit 09b1ef9
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/main/kotlin/com/github/denofevil/aurelia/Aurelia.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,12 @@ object Aurelia {
val jsonFile = PsiManager.getInstance(project).findFile(virtualFile)
val jsonObject = (jsonFile as? JsonFile)?.topLevelValue as? JsonObject

jsonObject?.findProperty("dependencies")?.let { dependenciesProp ->
val dependenciesObject = dependenciesProp.value as? JsonObject
val aureliaDependency = dependenciesObject?.findProperty("aurelia")
val aureliaCliDependency = dependenciesObject?.findProperty("aurelia-cli")
if (aureliaCliDependency != null || aureliaDependency != null) {
hasDependency = true
return@iterateChildrenRecursively false
}
val dependencies = jsonObject?.findProperty("dependencies")?.value as? JsonObject
val devDependencies = jsonObject?.findProperty("devDependencies")?.value as? JsonObject

if (hasAureliaDependency(dependencies) || hasAureliaDependency(devDependencies)) {
hasDependency = true
return@iterateChildrenRecursively false
}
}

Expand All @@ -61,4 +59,13 @@ object Aurelia {

return hasDependency
}

private fun hasAureliaDependency(jsonObject: JsonObject?): Boolean {
if (jsonObject == null) return false

val aureliaDependency = jsonObject.findProperty("aurelia")
val aureliaCliDependency = jsonObject.findProperty("aurelia-cli")

return aureliaDependency != null || aureliaCliDependency != null
}
}

0 comments on commit 09b1ef9

Please sign in to comment.