Skip to content

Commit

Permalink
Fix PATH under Windows if jrePath is given
Browse files Browse the repository at this point in the history
The quotes are not needed (anymore?)
Also it is enough to have only jrePath on PATH
  • Loading branch information
adangel committed Nov 29, 2024
1 parent 7f4f161 commit 5a4374a
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/lib/apexPmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,22 +141,17 @@ export class ApexPmd {

let env : NodeJS.ProcessEnv = {};
if (this.config.jrePath) {
if (os.platform() === 'win32') {
// add surrounding quotes in case jrePath contains spaces
env["PATH"] = `"${path.join(this.config.jrePath, 'bin')}${path.delimiter}${process.env.PATH}"`;
} else {
env["PATH"] = `${path.join(this.config.jrePath, 'bin')}${path.delimiter}${process.env.PATH}`;
}
env["PATH"] = `${path.join(this.config.jrePath, 'bin')}`;
}

const cmd = `java -cp "${path.join(pmdBinPath, 'lib')}${path.sep}*${path.delimiter}${classPath}" net.sourceforge.pmd.cli.PmdCli check ${pmdKeys}`;

this.outputChannel.appendLine(`node: ${process.version}`);
this.outputChannel.appendLine(`env: ${JSON.stringify(env)}`);
this.outputChannel.appendLine(`custom env: ${JSON.stringify(env)}`);
this.outputChannel.appendLine('PMD Command: ' + cmd);

const pmdCmd = ChildProcess.exec(cmd, {
env: {...process.env, ...env},
env: {...process.env, ...env}, // provides default env and maybe overwrites PATH
maxBuffer: Math.max(commandBufferSize, 1) * 1024 * 1024,
});

Expand Down

0 comments on commit 5a4374a

Please sign in to comment.