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

Add a configuration setting for a PATH prefix #98

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
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
3 changes: 3 additions & 0 deletions examples/path_shim_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
p `which ruby`
p `env`
p RUBY_VERSION
4 changes: 4 additions & 0 deletions lib/script-view.coffee
Original file line number Diff line number Diff line change
@@ -152,6 +152,10 @@ class ScriptView extends View

run: (command, args) ->
atom.emit("achievement:unlock", {msg: "Homestar Runner"})
# Prepend the user defined path
path_prefix = atom.config.get('script.path_prefix')
if path_prefix
process.env.PATH = [path_prefix, process.env.PATH].join(':')
Copy link
Member

Choose a reason for hiding this comment

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

Is there a built in that makes sure to pick the right separator for the OS in use?

I've been noticing more and more Win32 related items in Atom internals, so we should be prepped for it.

Copy link
Member

Choose a reason for hiding this comment

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

This is going to prepend path_prefix to process.env.PATH every single time run executes.

Copy link
Member

Choose a reason for hiding this comment

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

The platform specific delimiter is path.delimiter.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is going to prepend path_prefix to process.env.PATH every single time run executes.

I'll look into changing this when I have a minute to site and hack away at this.

The platform specific delimiter is path.delimiter.

I didn't think to look into using a path delimiter vs. :. Assuming *nix is bad though. 😆

Copy link
Member

Choose a reason for hiding this comment

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

path.delimiter is a bit of a misnomer, as it means the delimiter for the environment variable for path not the directory delimiter. 😅

It will use : on *.nix and ; on Windows.


# Default to where the user opened atom
options =
7 changes: 7 additions & 0 deletions lib/script.coffee
Original file line number Diff line number Diff line change
@@ -3,11 +3,18 @@ ScriptOptionsView = require './script-options-view'
ScriptOptions = require './script-options'

module.exports =
configDefaults:
path_prefix: null

scriptView: null
scriptOptionsView: null
scriptOptions: null

activate: (state) ->
# TODO: Do we have to set a default for empty?
atom.config.setDefaults "script",
path_prefix: null

@scriptOptions = new ScriptOptions()
@scriptView = new ScriptView(state.scriptViewState, @scriptOptions)
@scriptOptionsView = new ScriptOptionsView(@scriptOptions)