[Gradle, JS] Separately add arguments for kotlin npm install
^KT-49902 fixed
This commit is contained in:
+50
-4
@@ -28,10 +28,7 @@ import org.junit.jupiter.api.condition.DisabledIf
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import java.util.zip.ZipFile
|
||||
import kotlin.io.path.appendText
|
||||
import kotlin.io.path.extension
|
||||
import kotlin.io.path.name
|
||||
import kotlin.io.path.readText
|
||||
import kotlin.io.path.*
|
||||
import kotlin.streams.toList
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFalse
|
||||
@@ -1084,4 +1081,53 @@ class GeneralKotlin2JsGradlePluginIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("Yarn ignore scripts")
|
||||
@GradleTest
|
||||
fun testYarnIgnoreScripts(gradleVersion: GradleVersion) {
|
||||
project("nodeJsDownload", gradleVersion) {
|
||||
buildGradleKts.modify {
|
||||
it + "\n" +
|
||||
"""
|
||||
dependencies {
|
||||
implementation(npm("puppeteer", "11.0.0"))
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
build("assemble") {
|
||||
assert(
|
||||
projectPath
|
||||
.resolve("build")
|
||||
.resolve("js")
|
||||
.resolve("node_modules")
|
||||
.resolve("puppeteer")
|
||||
.resolve(".local-chromium")
|
||||
.notExists()
|
||||
) {
|
||||
"Chromium should not be installed with --ignore-scripts"
|
||||
}
|
||||
}
|
||||
buildGradleKts.modify {
|
||||
it + "\n" +
|
||||
"""
|
||||
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin> {
|
||||
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension>().ignoreScripts = false
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
build("clean")
|
||||
|
||||
build("assemble") {
|
||||
assertDirectoryExists(
|
||||
projectPath
|
||||
.resolve("build")
|
||||
.resolve("js")
|
||||
.resolve("node_modules")
|
||||
.resolve("puppeteer")
|
||||
.resolve(".local-chromium")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-3
@@ -35,9 +35,13 @@ abstract class YarnBasics : NpmApi {
|
||||
args: List<String>
|
||||
) {
|
||||
services.execWithProgress(description) { exec ->
|
||||
val arguments = args +
|
||||
if (logger.isDebugEnabled) "--verbose" else "" +
|
||||
if (yarn.ignoreScripts) "--ignore-scripts" else ""
|
||||
val arguments = args
|
||||
.plus(
|
||||
if (logger.isDebugEnabled) "--verbose" else ""
|
||||
)
|
||||
.plus(
|
||||
if (yarn.ignoreScripts) "--ignore-scripts" else ""
|
||||
).filter { it.isNotEmpty() }
|
||||
|
||||
val nodeExecutable = nodeJs.nodeExecutable
|
||||
exec.environment(
|
||||
|
||||
+1
@@ -54,6 +54,7 @@ open class YarnPlugin : Plugin<Project> {
|
||||
kotlinNpmInstall.configure {
|
||||
it.dependsOn(rootPackageJson)
|
||||
it.dependsOn(setupTask)
|
||||
it.inputs.property("ignoreScripts", { yarnRootExtension.ignoreScripts })
|
||||
}
|
||||
|
||||
tasks.register("yarn" + CleanDataTask.NAME_SUFFIX, CleanDataTask::class.java) {
|
||||
|
||||
Reference in New Issue
Block a user