Skip to content

Commit

Permalink
Add Aurelia detection when aurelia-cli is in the devDependencies sect…
Browse files Browse the repository at this point in the history
…ion of package.json
  • Loading branch information
BartBM committed Sep 1, 2024
1 parent 5b9a3a7 commit 98c62e8
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 98c62e8

Please sign in to comment.