Skip to content

Commit

Permalink
chore(node): Slightly simplify Yarn code to get package details
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Sep 13, 2024
1 parent 521bd69 commit c725523
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions plugins/package-managers/node/src/main/kotlin/Yarn.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,12 @@ class Yarn(

val process = run(workingDir, "info", "--json", packageName)

return Json.parseToJsonElement(process.stdout).jsonObject["data"]?.let {
val data = Json.parseToJsonElement(process.stdout).jsonObject["data"]?.also {
yarnInfoCache.write(packageName, it.toString())
parsePackageJson(it)
} ?: run {
Json.parseToJsonElement(process.stderr).jsonObject["data"].let {
logger.warn { "Error running '${process.commandLine}' in directory $workingDir: $it" }
parsePackageJson(checkNotNull(it))
}
} ?: checkNotNull(Json.parseToJsonElement(process.stderr).jsonObject["data"]).also {
logger.warn { "Error running '${process.commandLine}' in directory $workingDir: $it" }
}

return parsePackageJson(data)
}
}

0 comments on commit c725523

Please sign in to comment.