Skip to content

Commit

Permalink
Add fix-path option.
Browse files Browse the repository at this point in the history
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 AtomLinter#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 `fix-path` dependency.
  • Loading branch information
lexicalunit committed Dec 4, 2015
1 parent 57ca78d commit b7a717e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions lib/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"atom": ">0.180.0"
},
"dependencies": {
"atom-linter": "^3.0.0"
"atom-linter": "^3.0.0",
"fix-path": "^1.0.0"
},
"providedServices": {
"linter": {
Expand Down

0 comments on commit b7a717e

Please sign in to comment.