Skip to content

Commit

Permalink
Handle spaces in user name on Windows (#117)
Browse files Browse the repository at this point in the history
Wrap binary path in spaces for execFile
  • Loading branch information
danieledler authored Apr 27, 2020
1 parent 219b3a5 commit ccc94e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "raxmlgui",
"productName": "raxmlGUI",
"version": "2.0.0-beta.7",
"version": "2.0.0-beta.9",
"private": true,
"author": "AntonelliLab <raxmlgui.help@gmail.com>",
"license": "AGPL-3.0",
Expand Down
13 changes: 8 additions & 5 deletions src/main/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ process.on('unhandledRejection', error => {
});

const exec = util.promisify(childProcess.exec);
const execFile = util.promisify(childProcess.execFile);

const state = {
processes: {},
Expand Down Expand Up @@ -179,9 +180,11 @@ ipcMain.on(ipc.RUN_START, async (event, { id, args, binaryName, outputDir, outpu
}
}

console.log(`Try executing binary by running '${binaryPath} -v'...`);
console.log(`Try executing binary by running '"${binaryPath}" -v'...`);
try {
const { stdout, stderr } = await exec(`${binaryPath} -v`);
const { stdout, stderr } = await execFile(`"${binaryPath}"`, ['-v'], {
shell: electronUtil.is.windows,
});
console.log(stdout);
if (stderr) {
console.error('Error:', stderr);
Expand All @@ -202,7 +205,7 @@ ipcMain.on(ipc.RUN_START, async (event, { id, args, binaryName, outputDir, outpu
if (checkFlags) {
for (const arg of args) {
try {
const { stdout, stderr } = await exec(`${binaryPath} ${arg.join(' ')} --flag-check`, {
const { stdout, stderr } = await exec(`"${binaryPath}" ${arg.join(' ')} --flag-check`, {
shell: electronUtil.is.windows,
});
console.log(stdout, stderr);
Expand All @@ -218,7 +221,7 @@ ipcMain.on(ipc.RUN_START, async (event, { id, args, binaryName, outputDir, outpu
let exitCode = 0;
for (const arg of args) {
try {
console.log(`Run ${binaryName} with args:`, arg)
console.log(`Run '${binaryName}' with args:`, arg)
exitCode = await runProcess(id, event, binaryPath, arg);
if (exitCode !== 0) {
break;
Expand Down Expand Up @@ -274,7 +277,7 @@ function spawnProcess(binaryPath, args) {
// const binaryDir = path.dirname(binaryPath);
// const binaryName = path.basename(binaryPath);

const proc = childProcess.execFile(binaryPath, args, {
const proc = childProcess.execFile(`"${binaryPath}"`, args, {
// stdio: 'pipe',
// cwd: os.homedir(),
// env: { PATH: `${process.env.path}:${binaryDir}` },
Expand Down

0 comments on commit ccc94e2

Please sign in to comment.