-
Notifications
You must be signed in to change notification settings - Fork 743
feat: add tilde expansion to expand() #293
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
Conversation
|
This works right now with the old This still needs to be tested on Windows. |
|
For future reference, this prefers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use os-homedir instead? I don't really feel like we need to reinvent the wheel. (It's also not really that big a deal either way).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In terms of implementation, this should be very similar. I opted to just code it myself because it cuts out a dependency and it was only a few lines of code. I think it's easier to keep small snippets in the code base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
This adds tilde expansion to the expand() function. Arguments starting with '~/' will have the tilde expanded to the user's home directory, as with Bash.
|
Did this ever get tested on Windows? |
|
@ariporad good catch! I did test it on my Windows 7 machine. It passes the cd('~');
echo(pwd());
cd('~/Documents'); // still works, evven with a forward slash
echo(pwd());
cd('~');
echo(pwd()); |
|
That was testing on Windows 7 64 bit, Node v5, running through |
|
LGTM! |
feat: add tilde expansion to expand()
This adds tilde expansion to the expand() function. Arguments starting with '~/'
will have the tilde expanded to the user's home directory, as with Bash.
Also, if an argument is simply
~, then it will expand to the home directory as well.This does not support all of Bash's tilde expansion (not sure if this would be difficult). For example: