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 optional `fix-path` dependency (avoid issues with non-OS X OS's).
  • Loading branch information
lexicalunit committed Dec 4, 2015
1 parent 5f14f22 commit 47ccf59
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
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: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"dependencies": {
"atom-linter": "^3.0.0"
},
"optionalDependencies": {
"fix-path": "^1.0.0"
},
"providedServices": {
"linter": {
"versions": {
Expand Down

0 comments on commit 47ccf59

Please sign in to comment.