@@ -24,17 +24,26 @@ abstract class NpmExecRunner {
24
24
project : ProjectApiHelper ,
25
25
extension : NodeExtension ,
26
26
nodeExecConfiguration : NodeExecConfiguration ,
27
- variants : VariantComputer
27
+ variants : VariantComputer ,
28
28
): ExecResult {
29
29
val npmExecConfiguration = NpmExecConfiguration (
30
- " npm"
31
- ) { variantComputer, nodeExtension, npmBinDir -> variantComputer.computeNpmExec(nodeExtension, npmBinDir) }
30
+ command = " npm" ,
31
+ commandExecComputer = { variantComputer, nodeExtension, npmBinDir ->
32
+ variantComputer.computeNpmExec(
33
+ nodeExtension,
34
+ npmBinDir
35
+ )
36
+ }
37
+ )
32
38
return executeCommand(
33
- project,
34
- extension,
35
- NpmProxy .addProxyEnvironmentVariables(extension.nodeProxySettings.get(), nodeExecConfiguration),
36
- npmExecConfiguration,
37
- variants
39
+ project = project,
40
+ extension = extension,
41
+ nodeExecConfiguration = NpmProxy .addProxyEnvironmentVariables(
42
+ proxySettings = extension.nodeProxySettings.get(),
43
+ nodeExecConfiguration = nodeExecConfiguration
44
+ ),
45
+ npmExecConfiguration = npmExecConfiguration,
46
+ variantComputer = variants
38
47
)
39
48
}
40
49
@@ -78,9 +87,13 @@ abstract class NpmExecRunner {
78
87
if (executableAndScript.script != null ) listOf (executableAndScript.script) else listOf ()
79
88
val args = argsPrefix.plus(nodeExecConfiguration.command)
80
89
ExecConfiguration (
81
- executableAndScript.executable, args, additionalBinPath,
82
- nodeExecConfiguration.environment, nodeExecConfiguration.workingDir,
83
- nodeExecConfiguration.ignoreExitValue, nodeExecConfiguration.execOverrides
90
+ executable = executableAndScript.executable,
91
+ args = args,
92
+ additionalBinPaths = additionalBinPath,
93
+ environment = nodeExecConfiguration.environment,
94
+ workingDir = nodeExecConfiguration.workingDir,
95
+ ignoreExitValue = nodeExecConfiguration.ignoreExitValue,
96
+ execOverrides = nodeExecConfiguration.execOverrides,
84
97
)
85
98
}
86
99
}
@@ -97,18 +110,34 @@ abstract class NpmExecRunner {
97
110
val nodeExecProvider = computeNodeExec(nodeExtension, nodeBinDirProvider)
98
111
val executableProvider =
99
112
npmExecConfiguration.commandExecComputer(variantComputer, nodeExtension, npmBinDirProvider)
100
- val isWindows = nodeExtension.resolvedPlatform.get().isWindows()
101
113
val npmScriptFileProvider =
102
- computeNpmScriptFile(nodeDirProvider, npmExecConfiguration.command, isWindows)
114
+ computeNpmScriptFile(nodeDirProvider, npmExecConfiguration.command, nodeExtension.resolvedPlatform)
115
+ return computeExecutable(
116
+ npmExecConfiguration.command,
117
+ nodeExtension,
118
+ executableProvider,
119
+ nodeExecProvider,
120
+ npmScriptFileProvider
121
+ )
122
+ }
123
+
124
+ private fun computeExecutable (
125
+ command : String ,
126
+ nodeExtension : NodeExtension ,
127
+ executableProvider : Provider <String >,
128
+ nodeExecProvider : Provider <String >,
129
+ npmScriptFileProvider : Provider <String >,
130
+ ): Provider <ExecutableAndScript > {
103
131
return zip(
104
- nodeExtension.download, nodeExtension.nodeProjectDir, executableProvider, nodeExecProvider,
132
+ nodeExtension.download,
133
+ nodeExtension.nodeProjectDir,
134
+ executableProvider,
135
+ nodeExecProvider,
105
136
npmScriptFileProvider
106
- ).map {
107
- val (download, nodeProjectDir, executable, nodeExec,
108
- npmScriptFile) = it
137
+ ).map { (download, nodeProjectDir, executable, nodeExec, npmScriptFile) ->
109
138
if (download) {
110
139
val localCommandScript = nodeProjectDir.dir(" node_modules/npm/bin" )
111
- .file(" ${npmExecConfiguration. command} -cli.js" ).asFile
140
+ .file(" ${command} -cli.js" ).asFile
112
141
if (localCommandScript.exists()) {
113
142
return @map ExecutableAndScript (nodeExec, localCommandScript.absolutePath)
114
143
} else if (! File (executable).exists()) {
@@ -121,7 +150,7 @@ abstract class NpmExecRunner {
121
150
122
151
private data class ExecutableAndScript (
123
152
val executable : String ,
124
- val script : String? = null
153
+ val script : String? = null ,
125
154
)
126
155
127
156
private fun computeAdditionalBinPath (
0 commit comments