[Gradle, JS] Add nodeArgs

This commit is contained in:
Ilya Goncharov
2020-05-18 12:00:08 +03:00
parent b201ff0168
commit 549797c719
4 changed files with 25 additions and 5 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -39,7 +39,12 @@ class DukatExecutor(
args.addAll(dTsFiles.map { it.absolutePath })
compilation.npmProject.useTool(exec, "dukat/bin/dukat-cli.js", *args.toTypedArray())
compilation.npmProject.useTool(
exec,
"dukat/bin/dukat-cli.js",
listOf(),
args
)
}
}
}
@@ -78,10 +78,15 @@ open class NpmProject(val compilation: KotlinJsCompilation) {
private val rootNodeModules: NpmProjectModules?
get() = NpmProjectModules(nodeJs.rootPackageDir)
fun useTool(exec: ExecSpec, tool: String, vararg args: String) {
fun useTool(
exec: ExecSpec,
tool: String,
nodeArgs: List<String> = listOf(),
args: List<String>
) {
exec.workingDir = dir
exec.executable = nodeJs.requireConfigured().nodeExecutable
exec.args = listOf(require(tool)) + args
exec.args = nodeArgs + require(tool) + args
}
/**
@@ -126,6 +126,9 @@ open class KotlinWebpack : DefaultTask(), RequiresNpmDependencies {
@Input
var args: MutableList<String> = mutableListOf()
@Input
var nodeArgs: MutableList<String> = mutableListOf()
@Input
var sourceMaps: Boolean = true
@@ -149,6 +152,7 @@ open class KotlinWebpack : DefaultTask(), RequiresNpmDependencies {
execHandleFactory,
bin,
args,
nodeArgs,
KotlinWebpackConfig(
mode = mode,
entry = entry,
@@ -18,6 +18,7 @@ internal data class KotlinWebpackRunner(
val execHandleFactory: ExecHandleFactory,
val tool: String,
val args: List<String>,
val nodeArgs: List<String>,
val config: KotlinWebpackConfig
) {
fun execute() = npmProject.project.execWithErrorLogger("webpack") {
@@ -46,6 +47,11 @@ internal data class KotlinWebpackRunner(
args.addAll(this.args)
npmProject.useTool(execFactory, tool, *args.toTypedArray())
npmProject.useTool(
execFactory,
tool,
nodeArgs,
args
)
}
}