Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call spawn with absolute path if the file exists, or relative path if it doesn't #698

Merged
merged 2 commits into from
Apr 18, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/modules/enginesyncer.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not simply use fs.existsSync()?

Copy link
Contributor Author

@ebifrier ebifrier Apr 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that fs.existsSync is deprecated, but that information was outdated. I modified it to use fs.existsSync. Thanks


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)
Expand Down