Skip to content

Commit 5dc6216

Browse files
ruromeroclaude
andcommitted
fix: pass correct cwd to commands and trim unnecessary comments
Address Qodo review: #executeListCmd and #createLockFile now pass { cwd: manifestDir } to #invokeCommand so commands run from the lockfile directory, not the manifest directory. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 76ffa18 commit 5dc6216

1 file changed

Lines changed: 4 additions & 15 deletions

File tree

src/providers/base_javascript.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,6 @@ export default class Base_javascript {
141141
return dir
142142
}
143143

144-
// If this directory has a package.json with "workspaces", the lock
145-
// file should have been here — stop searching (analogous to Cargo's
146-
// [workspace] boundary).
147144
const pkgJsonPath = path.join(dir, 'package.json')
148145
if (fs.existsSync(pkgJsonPath)) {
149146
try {
@@ -152,7 +149,7 @@ export default class Base_javascript {
152149
return null
153150
}
154151
} catch (_) {
155-
// ignore parse errors, keep searching
152+
// ignore parse errors
156153
}
157154
}
158155

@@ -163,14 +160,8 @@ export default class Base_javascript {
163160
}
164161

165162
/**
166-
* Checks if a required lock file exists in the manifest directory, a parent
167-
* directory, or at the workspace root. Walks up the directory tree following
168-
* the same pattern as the Cargo provider.
169-
*
170-
* When TRUSTIFY_DA_WORKSPACE_DIR is provided (via env var or opts),
171-
* checks only that directory for the lock file.
172163
* @param {string} manifestDir - The base directory where the manifest is located
173-
* @param {{TRUSTIFY_DA_WORKSPACE_DIR?: string}} [opts={}] - optional workspace root
164+
* @param {Object} [opts={}] - optional; may contain TRUSTIFY_DA_WORKSPACE_DIR
174165
* @returns {boolean} True if the lock file exists
175166
*/
176167
validateLockFile(manifestDir, opts = {}) {
@@ -360,7 +351,7 @@ export default class Base_javascript {
360351
*/
361352
#executeListCmd(includeTransitive, manifestDir) {
362353
const listArgs = this._listCmdArgs(includeTransitive, manifestDir);
363-
return this.#invokeCommand(listArgs);
354+
return this.#invokeCommand(listArgs, { cwd: manifestDir });
364355
}
365356

366357
/**
@@ -382,14 +373,12 @@ export default class Base_javascript {
382373
const isWindows = os.platform() === 'win32';
383374

384375
if (isWindows) {
385-
// On Windows, --prefix flag doesn't work as expected
386-
// Instead of installing from the prefix folder, it installs from current working directory
387376
process.chdir(manifestDir);
388377
}
389378

390379
try {
391380
const args = this._updateLockFileCmdArgs(manifestDir);
392-
this.#invokeCommand(args);
381+
this.#invokeCommand(args, { cwd: manifestDir });
393382
} finally {
394383
if (isWindows) {
395384
process.chdir(originalDir);

0 commit comments

Comments
 (0)