Skip to content

Commit 22bc155

Browse files
authored
fix: manifest dir as working directory (#165)
## Description Use the working dir in the `runProcess` command instead of using `--prefix` **Related issue (if any):** fixes #164 ## Checklist - [x] I have followed this repository's contributing guidelines. - [x] I will adhere to the project's code of conduct. Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
1 parent 752384e commit 22bc155

2 files changed

Lines changed: 4 additions & 25 deletions

File tree

src/main/java/com/redhat/exhort/providers/JavaScriptNpmProvider.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,11 @@ protected String lockFileName() {
3939

4040
@Override
4141
protected String[] updateLockFileCmd(Path manifestDir) {
42-
return new String[] {
43-
packageManager(), "i", "--package-lock-only", "--prefix", manifestDir.toString()
44-
};
42+
return new String[] {packageManager(), "i", "--package-lock-only"};
4543
}
4644

4745
@Override
4846
protected String[] listDepsCmd(boolean includeTransitive, Path manifestDir) {
49-
if (manifestDir != null) {
50-
return new String[] {
51-
packageManager(),
52-
"ls",
53-
includeTransitive ? "--all" : "--depth=0",
54-
"--omit=dev",
55-
"--package-lock-only",
56-
"--json",
57-
"--prefix",
58-
manifestDir.toString()
59-
};
60-
}
6147
return new String[] {
6248
packageManager(),
6349
"ls",

src/main/java/com/redhat/exhort/providers/JavaScriptProvider.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,10 @@ protected JsonNode buildDependencyTree(boolean includeTransitive) throws JsonPro
222222
}
223223
var createPackageLock = updateLockFileCmd(manifestDir);
224224
// execute the clean command
225-
Operations.runProcess(createPackageLock, getExecEnv());
226-
String[] allDeps;
227-
Path workDir = null;
228-
if (!manifest.path.getParent().toString().trim().contains(" ")) {
229-
allDeps = listDepsCmd(includeTransitive, manifestDir);
230-
} else {
231-
allDeps = listDepsCmd(includeTransitive, null);
232-
workDir = manifest.path.getParent();
233-
}
225+
Operations.runProcess(manifestDir, createPackageLock, getExecEnv());
226+
String[] allDeps = listDepsCmd(includeTransitive, manifestDir);
234227
// execute the clean command
235-
String output = Operations.runProcessGetOutput(workDir, allDeps, getExecEnvAsArgs());
228+
String output = Operations.runProcessGetOutput(manifestDir, allDeps, getExecEnvAsArgs());
236229
if (debugLoggingIsNeeded()) {
237230
log.info(
238231
String.format("Listed Install Packages in Json : %s %s", System.lineSeparator(), output));

0 commit comments

Comments
 (0)