feat: add tilde expansion to expand()#293
feat: add tilde expansion to expand()#293ariporad merged 1 commit intoshelljs:masterfrom nfischer:feat-home-directory-tilde
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.
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.
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.
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: