From 47ccf59314993d9e5060047ab4e3622d6777fcac Mon Sep 17 00:00:00 2001 From: lexicalunit Date: Fri, 4 Dec 2015 14:08:47 -0600 Subject: [PATCH] Add fix-path option. On OS X electron frequently does not seem to pick up the PATH setting correctly when launching Atom from a GUI, for example the Dock. This means that shellcheck can not be found. One workaround is to specify the absolute path to shellcheck, but this can be done automatically. This provides a much better experience for users on OS X. This should also resolve issue #7 for many users. - Adds `enableFixPath` option. - Adds documentation for option to README. - Adds observer for option, once turned on it can't be reversed. - Defaults `enableFixPath` to true for 'darwin` (OS X) platform. - Provides user documentation for option, indicating its use in OS X. - Adds optional `fix-path` dependency (avoid issues with non-OS X OS's). --- README.md | 1 + lib/main.coffee | 9 +++++++++ package.json | 3 +++ 3 files changed, 13 insertions(+) diff --git a/README.md b/README.md index c2edd38..8089e77 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ You can configure linter-json by editing ~/.atom/config.cson (choose Open Your C ``` 'linter-shellcheck': 'shellcheckExecutablePath': null #shellcheck path. run 'which shellcheck' to find the path + 'enableFixPath': enables fix-path optimization; useful when running Atom on OS X to fix PATH issues ``` ## Contributing diff --git a/lib/main.coffee b/lib/main.coffee index 48768b2..3cf69d3 100644 --- a/lib/main.coffee +++ b/lib/main.coffee @@ -10,6 +10,11 @@ module.exports = type: 'boolean' title: 'Enable Notice Messages' default: false + enableFixPath: + type: 'boolean' + title: 'Enable fix-path' + description: 'Fix the `$PATH` on OS X when Atom is run from a GUI app.' + default: process.platform is 'darwin' activate: -> @subscriptions = new CompositeDisposable @@ -20,6 +25,10 @@ module.exports = @subscriptions.add atom.config.observe 'linter-shellcheck.enableNotice', (enableNotice) => @enableNotice = enableNotice + @subscriptions.add atom.config.observe 'linter-shellcheck.enableFixPath', + (enableFixPath) -> + # can not reverse fix-path once loaded + require('fix-path')() if enableFixPath deactivate: -> @subscriptions.dispose() diff --git a/package.json b/package.json index 1edf874..7c5aa87 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,9 @@ "dependencies": { "atom-linter": "^3.0.0" }, + "optionalDependencies": { + "fix-path": "^1.0.0" + }, "providedServices": { "linter": { "versions": {