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

Force hardcoded paths to CLI beautifiers #164

Closed
3 tasks done
Glavin001 opened this issue Dec 27, 2014 · 4 comments
Closed
3 tasks done

Force hardcoded paths to CLI beautifiers #164

Glavin001 opened this issue Dec 27, 2014 · 4 comments

Comments

@Glavin001
Copy link
Owner

There have been many problems with the $PATH and using https://github.com/Glavin001/atom-beautify/blob/master/lib/langs/cli-beautify.coffee#L37-L42 to automatically fix the $PATH. This is not working out.

  • Remove
    # We need the $PATH to be correct when executing the command.
    # This should normalize the $PATH
    # by calling the external files that would usually
    # change the $PATH variable on user login.
    $path = "[ -f ~/.bash_profile ] && source ~/.bash_profile > /dev/null 2>&1;"
    $path += "[ -f ~/.bashrc ] && source ~/.bashrc > /dev/null 2>&1;"
    and force CLI beautifiers to have hardcoded paths in config
  • Use
    # We need the $PATH to be correct when executing the command.
    # This should normalize the $PATH
    # by calling the external files that would usually
    # change the $PATH variable on user login.
    $path = "[ -f ~/.bash_profile ] && source ~/.bash_profile > /dev/null 2>&1;"
    $path += "[ -f ~/.bashrc ] && source ~/.bashrc > /dev/null 2>&1;"
    code to suggest if the beautifier's path is current empty
  • Change $PATH (for auto-detecting paths of CLI beautifiers)
@Glavin001
Copy link
Owner Author

Use which command in Mac and Linux to determine executable file's path.
Use where.exe for Windows: http://stackoverflow.com/questions/304319/is-there-an-equivalent-of-which-on-the-windows-command-line

@Glavin001
Copy link
Owner Author

Ended up using code from script-runner by @ioquatix: https://github.com/ioquatix/script-runner/blob/v1.5.0/lib/script-runner.coffee#L45-L63
This will auto-detect all shell environment variables, including PATH. This means we can get rid of the hardcoded CLI executable paths entirely!

Glavin001 added a commit that referenced this issue Apr 30, 2015
CLI beautifiers no longer need hardcoded/fixed paths
to their executable, since the PATH and
other environment variables are being auto-detected
@ioquatix
Copy link

ioquatix commented May 1, 2015

Be careful with that code it's a bit unstable.. not like, in that it doesn't work.. just that it's hard to guarantee it works cross platform. Interactive login shells sometimes do weird things, like print out headers, etc. We changed it a couple of times to try and get the correct cross platform behaviour, it's working well at the moment, but if you depend on it perhaps it should be a separate npm package so it can be updated independently.

@ioquatix
Copy link

ioquatix commented May 1, 2015

Okay, so you've motivated me to try making my first npm module.. with this code.

https://github.com/ioquatix/login-environment

@Glavin001 I've added you as a collaborator so feel free to make any changes. Then once it is good and makes sense, we can release a 1.0.0 release and that way any improvements to the code would be shared between both this project and script-runner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants