From a538e0b1eaa9e253a3466f58a08ef2c26b413069 Mon Sep 17 00:00:00 2001 From: ebifrier Date: Sat, 18 Apr 2020 01:08:22 +0900 Subject: [PATCH 1/2] Call spawn with absolute path if the file exists, or relative path if it doesn't. --- src/modules/enginesyncer.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/modules/enginesyncer.js b/src/modules/enginesyncer.js index d38b57dea..b859d6d32 100644 --- a/src/modules/enginesyncer.js +++ b/src/modules/enginesyncer.js @@ -1,4 +1,5 @@ import {remote} from 'electron' +import fs from 'fs' import EventEmitter from 'events' import {dirname, resolve} from 'path' import argvsplit from 'argv-split' @@ -87,8 +88,19 @@ export default class EngineSyncer extends EventEmitter { this.commands = [] this.treePosition = null - this.controller = new Controller(resolve(path), [...argvsplit(args)], { - cwd: dirname(resolve(path)) + let fileExistsSync = path => { + try { + fs.accessSync(path, fs.F_OK) + return true + } catch { + return false + } + } + + let absolutePath = resolve(path) + let executePath = fileExistsSync(absolutePath) ? absolutePath : path + this.controller = new Controller(executePath, [...argvsplit(args)], { + cwd: dirname(absolutePath) }) this.stateTracker = new ControllerStateTracker(this.controller) From cacbe2f7855eaaf4aaecf08d3a239664cabcd26e Mon Sep 17 00:00:00 2001 From: ebifrier Date: Sat, 18 Apr 2020 21:06:50 +0900 Subject: [PATCH 2/2] Use fs.existsSync --- src/modules/enginesyncer.js | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/modules/enginesyncer.js b/src/modules/enginesyncer.js index b859d6d32..6e578ebde 100644 --- a/src/modules/enginesyncer.js +++ b/src/modules/enginesyncer.js @@ -1,6 +1,6 @@ import {remote} from 'electron' -import fs from 'fs' import EventEmitter from 'events' +import {existsSync} from 'fs' import {dirname, resolve} from 'path' import argvsplit from 'argv-split' import {v4 as uuid} from 'uuid' @@ -88,17 +88,8 @@ export default class EngineSyncer extends EventEmitter { this.commands = [] this.treePosition = null - let fileExistsSync = path => { - try { - fs.accessSync(path, fs.F_OK) - return true - } catch { - return false - } - } - let absolutePath = resolve(path) - let executePath = fileExistsSync(absolutePath) ? absolutePath : path + let executePath = existsSync(absolutePath) ? absolutePath : path this.controller = new Controller(executePath, [...argvsplit(args)], { cwd: dirname(absolutePath) })