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 which command using npm module which #71

Merged
merged 4 commits into from
Mar 22, 2016
Merged

Add which command using npm module which #71

merged 4 commits into from
Mar 22, 2016

Conversation

khuongduybui
Copy link
Contributor

No description provided.

@khuongduybui
Copy link
Contributor Author

I vetted the source code of the which npm module myself to make sure it's a cross platform, pure-JS implementation.

@nfischer
Copy link
Collaborator

Haven't tested this yet, but I'm in favor of re-using existing modules if they're robust enough.

@khuongduybui does this also support things like:

$ export foo="cat"
$ which $foo # outputs path to cat

If so, could you add tests to the pre parser test file?

const results = cash.which('cmd');
console.log(typeof results);
results.should.not.equal('');
});
Copy link
Owner

Choose a reason for hiding this comment

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

It should be pretty easy tests for basic functionality. Not trying to re-handle all of the tests that the lib already provides, but a basic test or two that verifies the author didn't butcher the package on the latest update would be good.

@dthree
Copy link
Owner

dthree commented Mar 14, 2016

Hey looks great, thanks!!!

Added some notes. After this, should be good to merge!

@khuongduybui
Copy link
Contributor Author

@nfischer: it does work, I'll add a test.
@dthree: thanks for quick response, I will make the suggested changes

@nfischer
Copy link
Collaborator

What does this return in the case of which ls? Does this indicate the ls implementation inside cash, or does this return the path to ls on the system? Not sure which behavior would be better in our case, but it's something to think about (and might be worth clarifying in the documentation).

I could see a user being confused about why which ls returns /bin/ls when executing ls actually execute's cash's ls command. But then again, we see the same issue in Bash, since which pwd refers to /bin/pwd and yet the pwd command usually calls a builtin.

@dthree
Copy link
Owner

dthree commented Mar 14, 2016

Should probably just do the system one - if Cash is installed on Windows globally, it will return the Cash one anyway.

@khuongduybui
Copy link
Contributor Author

@nfischer: I'm with @dthree here. Wikipedia (which we all agree is the ultimate source of truth, don't we?) says "which is a Unix command used to identify the location of executables." This which command does exactly that.

@nfischer
Copy link
Collaborator

Yeah, I'd agree it's probably the better route (I personally hate the which command for this specific reason). This might motivate implementing a command like type to provide nicer semantics (identifies builtins).

@khuongduybui
Copy link
Contributor Author

@dthree: ready for merge

@dthree
Copy link
Owner

dthree commented Mar 15, 2016

Thanks! Will do final review shortly.

dthree added a commit that referenced this pull request Mar 22, 2016
Add which command using npm module which
@dthree dthree merged commit 937ee91 into dthree:master Mar 22, 2016
@dthree
Copy link
Owner

dthree commented Mar 22, 2016

👍 sorry for the delay

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

Successfully merging this pull request may close these issues.

3 participants