Skip to content

Commit 651ecca

Browse files
authored
Fixed improper verification of the mocha installation (#1585)
1 parent 5d6bf55 commit 651ecca

File tree

1 file changed

+13
-7
lines changed
  • utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js

1 file changed

+13
-7
lines changed

utbot-intellij-js/src/main/kotlin/org/utbot/intellij/plugin/language/js/Utils.kt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,30 @@ fun getFrameworkLibraryPath(npmPackageName: String, model: JsTestsModel?): Strin
2222
return input.substringBefore(npmPackageName) + npmPackageName
2323
}
2424

25-
fun findFrameworkLibrary(npmPackageName: String, model: JsTestsModel): Boolean {
26-
val (bufferedReader, _) = JsCmdExec.runCommand(
25+
private fun npmListByFlag(model: JsTestsModel, flag: String): String {
26+
val (bufferReader, _) = JsCmdExec.runCommand(
2727
dir = model.project.basePath!!,
2828
shouldWait = true,
2929
timeout = 10,
30-
cmd = arrayOf(model.pathToNPM, "list", "-g")
30+
cmd = arrayOf(model.pathToNPM, "list", flag)
3131
)
32-
val checkForPackageText = bufferedReader.readText()
33-
bufferedReader.close()
34-
if (checkForPackageText == "") {
32+
val packages = bufferReader.readText()
33+
bufferReader.close()
34+
return packages
35+
}
36+
37+
fun findFrameworkLibrary(npmPackageName: String, model: JsTestsModel): Boolean {
38+
val packageText = npmListByFlag(model, "-g") + npmListByFlag(model, "-l")
39+
40+
if (packageText.isEmpty()) {
3541
Messages.showErrorDialog(
3642
model.project,
3743
"Node.js is not installed",
3844
"Generation Failed",
3945
)
4046
return false
4147
}
42-
return checkForPackageText.contains(npmPackageName)
48+
return packageText.contains(npmPackageName)
4349
}
4450

4551
fun installRequirement(pathToNPM: String, requirement: String, installingDir: String?): Pair<BufferedReader, BufferedReader> {

0 commit comments

Comments
 (0)