@@ -60,14 +60,17 @@ public class NpmBuildInfoExtractor implements BuildInfoExtractor<NpmProject> {
60
60
@ Override
61
61
public Build extract (NpmProject npmProject ) throws Exception {
62
62
String resolutionRepository = npmProject .getResolutionRepository ();
63
- List <String > installationArgs = npmProject .getInstallationArgs ();
63
+ List <String > commandArgs = npmProject .getCommandArgs ();
64
64
Path workingDir = npmProject .getWorkingDir ();
65
65
66
66
preparePrerequisites (resolutionRepository , workingDir );
67
- createTempNpmrc (workingDir , installationArgs );
68
- runInstall (workingDir , installationArgs );
67
+ createTempNpmrc (workingDir , commandArgs );
68
+ if (npmProject .isCiCommand ()) {
69
+ runCi (workingDir , commandArgs );
70
+ } else {
71
+ runInstall (workingDir , commandArgs );
72
+ }
69
73
restoreNpmrc (workingDir );
70
-
71
74
List <Dependency > dependencies = collectDependencies (workingDir );
72
75
String moduleId = StringUtils .isNotBlank (module ) ? module : npmPackageInfo .toString ();
73
76
return createBuild (dependencies , moduleId );
@@ -128,10 +131,10 @@ private void backupProjectNpmrc(Path workingDir) throws IOException {
128
131
Files .copy (npmrcPath , npmrcBackupPath , StandardCopyOption .COPY_ATTRIBUTES , StandardCopyOption .REPLACE_EXISTING );
129
132
}
130
133
131
- private void createTempNpmrc (Path workingDir , List <String > installationArgs ) throws IOException , InterruptedException {
134
+ private void createTempNpmrc (Path workingDir , List <String > commandArgs ) throws IOException , InterruptedException {
132
135
Path npmrcPath = workingDir .resolve (NPMRC_FILE_NAME );
133
136
Files .deleteIfExists (npmrcPath ); // Delete old npmrc file
134
- final String configList = npmDriver .configList (workingDir .toFile (), installationArgs );
137
+ final String configList = npmDriver .configList (workingDir .toFile (), commandArgs );
135
138
136
139
Properties npmrcProperties = new Properties ();
137
140
@@ -140,8 +143,8 @@ private void createTempNpmrc(Path workingDir, List<String> installationArgs) thr
140
143
JsonNode manifestTree = mapper .readTree (configList );
141
144
manifestTree .fields ().forEachRemaining (entry -> npmrcProperties .setProperty (entry .getKey (), entry .getValue ().asText ()));
142
145
// Since we run the get config cmd with "--json" flag, we don't want to force the json output on the new npmrc we write.
143
- // We will get json output only if it was explicitly required in the installation arguments.
144
- npmrcProperties .setProperty ("json" , String .valueOf (isJsonOutputRequired (installationArgs )));
146
+ // We will get json output only if it was explicitly required in the command arguments.
147
+ npmrcProperties .setProperty ("json" , String .valueOf (isJsonOutputRequired (commandArgs )));
145
148
146
149
// Save npm auth
147
150
npmrcProperties .putAll (npmAuth );
@@ -172,12 +175,12 @@ private void createTempNpmrc(Path workingDir, List<String> installationArgs) thr
172
175
* 2. --arg=value (true/false)
173
176
* 3. --arg value (true/false)
174
177
*/
175
- static boolean isJsonOutputRequired (List <String > installationArgs ) {
176
- int jsonIndex = installationArgs .indexOf ("--json" );
178
+ static boolean isJsonOutputRequired (List <String > commandArgs ) {
179
+ int jsonIndex = commandArgs .indexOf ("--json" );
177
180
if (jsonIndex > -1 ) {
178
- return jsonIndex == installationArgs .size () - 1 || !installationArgs .get (jsonIndex + 1 ).equals ("false" );
181
+ return jsonIndex == commandArgs .size () - 1 || !commandArgs .get (jsonIndex + 1 ).equals ("false" );
179
182
}
180
- return installationArgs .contains ("--json=true" );
183
+ return commandArgs .contains ("--json=true" );
181
184
}
182
185
183
186
/**
@@ -198,6 +201,10 @@ private void runInstall(Path workingDir, List<String> installationArgs) throws I
198
201
logger .info (npmDriver .install (workingDir .toFile (), installationArgs , logger ));
199
202
}
200
203
204
+ private void runCi (Path workingDir , List <String > installationArgs ) throws IOException {
205
+ logger .info (npmDriver .ci (workingDir .toFile (), installationArgs , logger ));
206
+ }
207
+
201
208
private void restoreNpmrc (Path workingDir ) throws IOException {
202
209
Path npmrcPath = workingDir .resolve (NPMRC_FILE_NAME );
203
210
Path npmrcBackupPath = workingDir .resolve (NPMRC_BACKUP_FILE_NAME );
0 commit comments