Skip to content

Commit 959f719

Browse files
authored
Add support for AVA4 (#55)
* Add support for AVA4 The cli.js-file have been moved to lib-folder, but it doesn't work as before. I'm not 100% sure why the file was targeted instead of the .bin-one, could have been as simple as not having to deal with .cmd in windows. Anyway, here comes a new solution; pick the first of these: 1. node_modules/ava/cli.js 2. node_modules/.bin/ava.cmd 3. node_modules/.bin/ava I haven't tested the .cmd one, as I don't have Windows here at the moment. Also had to tweak the settings, hope it doesn't break. * Update cli path calculation Either use entrypoints/cli.mjs for >=4 or ava/cli.js for <4. * Bumping plugin version IIRC this was a manual step. Bumping minor. This might even be a major, but hoping minor will do.
1 parent 0171837 commit 959f719

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
pluginGroup = no.eirikb.avatest
55
pluginName = AvaJavaScriptTestRunnerRunConfigurationGenerator
6-
pluginVersion = 1.5.0
6+
pluginVersion = 1.6.0
77
pluginSinceBuild = 202
88
pluginUntilBuild = 212.*
99
# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl

src/main/kotlin/no/eirikb/avatest/actions/AvaJavaScriptTestRunnerRunConfigurationGenerator.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.CommonDataKeys
2222
import com.intellij.openapi.actionSystem.PlatformDataKeys
2323
import com.intellij.openapi.fileEditor.FileDocumentManager
2424
import com.intellij.openapi.project.Project
25+
import com.intellij.openapi.project.guessProjectDir
2526
import com.intellij.openapi.vfs.VirtualFile
2627
import com.intellij.openapi.wm.ToolWindowId
2728
import com.intellij.psi.PsiElement
@@ -153,6 +154,13 @@ class AvaJavaScriptTestRunnerRunConfigurationGenerator : AnAction() {
153154
}
154155
node.workingDirectory = project.basePath
155156
node.inputPath = AppSettingsState.inputPath
157+
if (node.inputPath == null) {
158+
val projectDir = project.guessProjectDir()
159+
node.inputPath = listOf(
160+
"node_modules/ava/entrypoints/cli.mjs",
161+
"node_modules/ava/cli.js"
162+
).find { projectDir?.findFileByRelativePath(it)?.exists() == true }
163+
}
156164
node.name = getConfigurationName(fileName, testName)
157165
node.applicationParameters = getRunArguments(relPath, testName)
158166

src/main/kotlin/no/eirikb/avatest/settings/AppSettingsComponent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const val MARGIN_BOTTOM = 8
1414
class AppSettingsComponent {
1515
val panel: JPanel
1616
val myInputPathText = JBTextField()
17-
var inputPathText: String
17+
var inputPathText: String?
1818
get() = myInputPathText.text
1919
set(newText) {
2020
myInputPathText.text = newText

src/main/kotlin/no/eirikb/avatest/settings/AppSettingsState.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import com.intellij.util.xmlb.XmlSerializerUtil
77

88
@State(name = "no.eirikb.avatest.settings.AppSettingsState", storages = [Storage("SdkSettingsPlugin.xml")])
99
object AppSettingsState : PersistentStateComponent<AppSettingsState?> {
10-
var inputPath = "node_modules/ava/cli.js"
10+
var inputPath: String? = null
1111
var selectedCommand = true
1212
var npmScriptsText = ""
1313

0 commit comments

Comments
 (0)