Skip to content

Commit

Permalink
Fixes executable path quoting in Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
faelv committed Feb 29, 2020
1 parent 8880fcc commit d02a7ce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/composerCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,8 @@ class ComposerCommands extends vscode.Disposable {
const pickedFolder = await this.pickWorkspaceFolder()
if (!pickedFolder) { return }

const executablePath = ComposerSettings.getInstance().getExecutablePath(pickedFolder.folderUri)
const cmd = `"${executablePath}" show -d "${pickedFolder.folderUri.fsPath}"`
const executablePath = ComposerSettings.getInstance().getExecutablePath(pickedFolder.folderUri, true)
const cmd = `${executablePath} show -d "${pickedFolder.folderUri.fsPath}"`
const out = await vscode.window.withProgress(
{location: vscode.ProgressLocation.Window, title: strings.FETCHING_PACKAGES},
() => {
Expand Down Expand Up @@ -666,8 +666,8 @@ class ComposerCommands extends vscode.Disposable {
const pickedFolder = await this.pickWorkspaceFolder()
if (!pickedFolder) { return }

const executablePath = ComposerSettings.getInstance().getExecutablePath(pickedFolder.folderUri)
const cmd = `"${executablePath}" exec --list -d "${pickedFolder.folderUri.fsPath}"`
const executablePath = ComposerSettings.getInstance().getExecutablePath(pickedFolder.folderUri, true)
const cmd = `${executablePath} exec --list -d "${pickedFolder.folderUri.fsPath}"`
const out = await vscode.window.withProgress(
{location: vscode.ProgressLocation.Window, title: strings.FETCHING_BINARIES},
() => {
Expand Down
6 changes: 5 additions & 1 deletion src/composerSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,17 @@ class ComposerSettings extends vscode.Disposable {

/**
* @param {vscode.Uri | undefined} resource
* @param {boolean} quoting
* @returns {string}
*/
getExecutablePath(resource = undefined) {
getExecutablePath(resource = undefined, quoting = false) {
let exe = this.get(ComposerSettings.SECTION_EXECUTABLE_PATH, null, resource)
if (typeof exe !== 'string') {
exe = ComposerSettings.DEFAULT_EXECUTABLE
}
if (quoting && exe.indexOf(' ') > -1) {
exe = `"${exe}"`
}
return exe
}

Expand Down
4 changes: 2 additions & 2 deletions src/composerTaskProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ class ComposerTaskProvider extends vscode.Disposable {
/** @returns {string} */
get executablePath() {
if (!this._executablePath) {
this._executablePath = this.settings.getExecutablePath()
this._executablePath = this.settings.getExecutablePath(undefined, true)
}
return this._executablePath
}

/** @returns {Promise<void>} */
checkExecutablePath() {
return new Promise((resolve) => {
cp.exec(`"${this.executablePath}" --quiet`, (error) => {
cp.exec(`${this.executablePath} --quiet`, (error) => {
if (error) {
vscode.window.showErrorMessage(`${strings.EXT_NAME}: ${strings.EXE_PATH_INVALID_MSG}`)
this.output.appendLine(`${strings.SETTINGS} (${strings.EXE_PATH}): [${strings.INVALID}] ${this.executablePath}`)
Expand Down

0 comments on commit d02a7ce

Please sign in to comment.