@@ -32,17 +32,9 @@ abstract class NpmExecSource @Inject internal constructor(
32
32
) : ValueSource<NpmExecResult, NpmExecSource.Parameters> {
33
33
34
34
abstract class Parameters internal constructor() : NpmExecSpec(), ValueSourceParameters {
35
- // /**
36
- // * The `npm` executable.
37
- // *
38
- // * This could either be a path to the `npm` executable file,
39
- // * or the name of the `PATH` executable.
40
- // */
41
- // abstract val executable: Property<String>
42
35
abstract val ignoreExitValue: Property <Boolean >
43
36
abstract val workingDir: DirectoryProperty
44
37
abstract val npmCommand: ListProperty <String >
45
- // abstract val args: ListProperty<String>
46
38
}
47
39
48
40
@@ -66,8 +58,6 @@ abstract class NpmExecSource @Inject internal constructor(
66
58
command = command,
67
59
environment = parameters.environment.orNull.orEmpty(),
68
60
workingDir = parameters.workingDir.asFile.orNull,
69
- // ignoreExitValue = ignoreExitValue.get(),
70
- // execOverrides = execOverrides.orNull,
71
61
)
72
62
return executeNpmCommand(nodeExecConfiguration)
73
63
}
@@ -76,7 +66,7 @@ abstract class NpmExecSource @Inject internal constructor(
76
66
execConfiguration : ExecConfiguration
77
67
): Map <String , String > {
78
68
return mutableMapOf<String , String >().apply {
79
- if (parameters.includeSystemEnvironment.orNull == true ) {
69
+ if (parameters.includeSystemEnvironment.getOrElse( true ) ) {
80
70
putAll(System .getenv())
81
71
}
82
72
putAll(parameters.environment.get())
@@ -94,10 +84,7 @@ abstract class NpmExecSource @Inject internal constructor(
94
84
95
85
96
86
private fun executeNpmCommand (
97
- // project: ProjectApiHelper,
98
- // extension: NodeExtension,
99
87
nodeExecConfiguration : NodeExecConfiguration ,
100
- // variants: VariantComputer,
101
88
): NpmExecResult {
102
89
val npmExecConfiguration = NpmExecConfiguration (
103
90
command = " npm" ,
@@ -116,53 +103,26 @@ abstract class NpmExecSource @Inject internal constructor(
116
103
val proxiedNodeExecConfiguration = nodeExecConfiguration.copy(environment = proxiedEnvVars)
117
104
118
105
return executeCommand(
119
- // project = project,
120
- // extension = extension,
121
106
nodeExecConfiguration = proxiedNodeExecConfiguration,
122
107
npmExecConfiguration = npmExecConfiguration,
123
- // variantComputer = variants
124
108
)
125
109
}
126
110
127
- // private fun executeNpxCommand(
128
- // project: ProjectApiHelper,
129
- // extension: NodeExtension,
130
- // nodeExecConfiguration: NodeExecConfiguration,
131
- // variants: VariantComputer
132
- // ): ExecResult {
133
- // val npxExecConfiguration = NpmExecConfiguration("npx") { variantComputer, parameters, npmBinDir ->
134
- // variantComputer.computeNpxExec(parameters, npmBinDir)
135
- // }
136
- //
137
- // return executeCommand(project, extension, nodeExecConfiguration, npxExecConfiguration, variants)
138
- // }
139
-
140
111
private fun executeCommand (
141
- // project: ProjectApiHelper? = null,
142
- // extension: NodeExtension,
143
112
nodeExecConfiguration : NodeExecConfiguration ,
144
113
npmExecConfiguration : NpmExecConfiguration ,
145
- // variants: VariantComputer,
146
114
): NpmExecResult {
147
115
val execConfiguration =
148
116
computeExecConfiguration(npmExecConfiguration, nodeExecConfiguration)
149
- // val execRunner = ExecRunner()
150
- // return execRunner.execute(project, extension, execConfiguration)
151
117
152
118
ByteArrayOutputStream ().use { capturedOutput ->
153
119
val result = execOps.exec {
154
120
155
121
executable = execConfiguration.executable
156
122
args = execConfiguration.args
157
123
environment = computeEnvironment(execConfiguration)
158
- // isIgnoreExitValue = execConfiguration.ignoreExitValue
159
124
workingDir = computeWorkingDir(nodeProjectDir, execConfiguration)
160
-
161
- // executable = parameters.executable.get()
162
- // args = parameters.arguments.orNull.orEmpty()
163
- // environment = computeEnvironment()
164
- isIgnoreExitValue = parameters.ignoreExitValue.getOrElse(false )
165
- // workingDir = parameters.workingDir.get().asFile
125
+ isIgnoreExitValue = parameters.ignoreExitValue.getOrElse(true )
166
126
standardOutput = capturedOutput
167
127
errorOutput = capturedOutput
168
128
}
@@ -183,15 +143,11 @@ abstract class NpmExecSource @Inject internal constructor(
183
143
}
184
144
185
145
private fun computeExecConfiguration (
186
- // extension: NodeExtension,
187
146
npmExecConfiguration : NpmExecConfiguration ,
188
147
nodeExecConfiguration : NodeExecConfiguration ,
189
148
): ExecConfiguration {
190
149
val additionalBinPath = computeAdditionalBinPath()
191
150
val executableAndScript = computeExecutable(npmExecConfiguration)
192
- // return zip(additionalBinPathProvider, executableAndScriptProvider)
193
- // .map { (additionalBinPath, executableAndScript) ->
194
- // }
195
151
val argsPrefix =
196
152
if (executableAndScript.script != null ) listOf (executableAndScript.script) else listOf ()
197
153
val args = argsPrefix.plus(nodeExecConfiguration.command)
@@ -201,15 +157,12 @@ abstract class NpmExecSource @Inject internal constructor(
201
157
additionalBinPaths = additionalBinPath,
202
158
environment = nodeExecConfiguration.environment,
203
159
workingDir = nodeExecConfiguration.workingDir,
204
- // ignoreExitValue = nodeExecConfiguration.ignoreExitValue,
205
160
execOverrides = nodeExecConfiguration.execOverrides,
206
161
)
207
162
}
208
163
209
164
private fun computeExecutable (
210
- // parameters: NodeExtension,
211
165
npmExecConfiguration : NpmExecConfiguration ,
212
- // variantComputer: VariantComputer
213
166
): ExecutableAndScript {
214
167
val nodeDirProvider = parameters.resolvedNodeDir.get()
215
168
val npmDirProvider = computeNpmDir(nodeDirProvider)
@@ -316,25 +269,11 @@ abstract class NpmExecSource @Inject internal constructor(
316
269
*/
317
270
private fun computeNpmExec (npmBinDirProvider : Directory ): String {
318
271
return computeExec(
319
- // nodeExtension = nodeExtension,
320
272
binDirProvider = npmBinDirProvider,
321
273
configurationCommand = npmCommand.single(),
322
274
)
323
275
}
324
276
325
- // /**
326
- // * Get the expected node binary name, npx.cmd on Windows and npx everywhere else.
327
- // *
328
- // * Can be overridden by setting npxCommand.
329
- // */
330
- // private fun computeNpxExec(nodeExtension: NodeExtension, npmBinDirProvider: Directory): Provider<String> {
331
- // return computeExec(
332
- // nodeExtension,
333
- // npmBinDirProvider,
334
- // parameters.npxCommand, "npx", "npx.cmd"
335
- // )
336
- // }
337
-
338
277
/* *
339
278
* Compute the path for a given command, from a given binary directory, taking Windows into account
340
279
*/
@@ -374,21 +313,12 @@ abstract class NpmExecSource @Inject internal constructor(
374
313
val additionalBinPaths : List <String > = listOf(),
375
314
val environment : Map <String , String > = mapOf(),
376
315
val workingDir : File ? = null ,
377
- // val ignoreExitValue: Boolean = false,
378
316
val execOverrides : Action <ExecSpec >? = null
379
317
)
380
318
381
- // internal typealias CommandExecComputer = (
382
- // variantComputer: VariantComputer,
383
- // nodeExtension: NodeExtension,
384
- // npmBinDir: Provider<Directory>,
385
- // ) -> Provider<String>
386
-
387
319
private data class NpmExecConfiguration (
388
320
val command : String ,
389
321
val commandExecComputer : (
390
- // variantComputer: VariantComputer ,
391
- // nodeExtension: NodeExtension ,
392
322
npmBinDir: Directory ,
393
323
) -> String ,
394
324
)
@@ -414,13 +344,10 @@ abstract class NpmExecSource @Inject internal constructor(
414
344
}
415
345
}
416
346
417
-
418
347
private data class NodeExecConfiguration (
419
348
val command : List <String > = listOf(),
420
349
val environment : Map <String , String > = mapOf(),
421
350
val workingDir : File ? = null ,
422
- // val ignoreExitValue: Boolean = false,
423
351
val execOverrides : Action <ExecSpec >? = null
424
352
)
425
-
426
353
}
0 commit comments