From 5a4374a8a07517a79b9fb0432455237cca2af979 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 29 Nov 2024 11:11:12 +0100 Subject: [PATCH] Fix PATH under Windows if jrePath is given The quotes are not needed (anymore?) Also it is enough to have only jrePath on PATH --- src/lib/apexPmd.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/lib/apexPmd.ts b/src/lib/apexPmd.ts index a51f05a..f3d286b 100644 --- a/src/lib/apexPmd.ts +++ b/src/lib/apexPmd.ts @@ -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, });