Conversation
|
Doesn't shell.js have its own glob expansion function? |
|
Oh yeah, I'll fix that. |
|
Fixed. |
|
@ariporad Could you ping this with a push to trigger the CI? |
|
@nfischer: Done. |
|
Thank you! |
There was a problem hiding this comment.
Is it possible to use glob without adding it as a package dependency? I know some of the original maintainers wanted to keep dependencies at a minimum (#122 (comment)).
There was a problem hiding this comment.
Nevermind. Just tried it and saw that I do need to install it as a dependency. We might need to ping @arturadib and get his input on this in that case.
There was a problem hiding this comment.
@nfischer: I think it's not that big a deal. If a user is installing us, then they have npm installed. The whole node world favors small focused modules, which mean dependencies. This means that deps are the norm. It's not out of the ordinary. (As a matter of fact, I'd like to try and split this module up into some smaller ones).
However, if @arturadib wants to chime in, that's more than welcome.
There was a problem hiding this comment.
I agree with the philosophy of using modules where they make sense. I think we probably should take advantage of the glob module, since it seems to integrate fairly seemlessly with the existing code.
|
@nfischer @ariporad as you can probably tell from luckily in our case our package is pretty small and the problems low level enough that the Node core lib is mostly sufficient. when I do encounter cases where reinventing the wheel takes more than a dozen lines of code or so, I simply copy and paste the relevant snippet :) like this: https://github.com/shelljs/shelljs/blob/master/src/cp.js#L44-L51 (it's obviously a tradeoff as in this case we also don't benefit from a well maintained project upstream, but again, those are all tradeoffs) all this being said..... glob does seem like a good, well maintained library, and I think our code is reinventing the wheel a bit too much (and not that well), so let's go ahead and see if this is a good solution going forward. my main concern at this point is breaking existing users, so let's bump at least the minor when we release, and make sure thanks! |
|
@arturadib: Three things:
|
Unfortunately, your clever and thoughtful plan failed. You need to put the The goal of the glob module is to match Bash 4.3 pattern matching as closely as possible, so it's probably a great fit for shelljs's needs. Since this will certainly change some of your existing edge cases, it seems like it probably should be a major version bump for shelljs, just to be on the safe side. |
I agree. My vote is in favor of switching to glob. I think if reinventing the wheel is simple enough, it may be best to do it ourselves. In this case however, we're not very closely matching Bash globbing, so the switch is probably smart. It seems like we all agree we should give |
|
@nfischer: the more I think about it, the more I think that I want to submit a PR moving all the command boilerplate into common.js. I'm unfortunately extremely busy this week, but over the weekend I should have some time to do that. |
src/ls.js
Outdated
There was a problem hiding this comment.
I think if we change this to files = common.expand(files, { dot: options.all }), and update expand() to take glob's options as a second parameter, this will eliminate the dependency on glob here.
17a33c5 to
fd77b7e
Compare
|
@nfischer: Ok, moved all the globbing into common, and fixed listing files with no dots. |
|
Also rebased onto master. |
|
@ariporad looks like there's some conflicts now (probably due to the |
|
@nfischer: Hmm... I actually think that there's no way to salvage |
|
@ariporad could you push this into a branch on the main repo? I'll take a look at refactoring |
|
@nfischer: I did, but it won't work to update this PR. |
|
@ariporad we would have to push to a new branch and open that as a PR to replace this one I think. |
|
@nfischer: Yeah, or I can give you push access to my fork. Up to you. (I'd rather not loose all the discussion). |
^ even better idea, actually |
|
@nfischer: Ok, you've got push access. |
|
I'll take a look |
|
@nfischer: Ok, you've got push access. |
|
So it turns out that this PR actually is kind of far from working. It passes CI because |
|
@nfischer: that's what this does. (Take a look at the changes tab). What do you mean it doesn't work? |
|
@ariporad this completely modifies the behavior of ls() as well. Click on any run of the CI and notice how it says "all tests passed"... without listing any of the tests. Now click on any other PR and see that run-tests lists every test file (i.e. cat.js, cp.js, etc) before the words "all tests passed" |
|
@nfischer: Hmm... Let me look in to fixing that. |
|
@ariporad I don't think you can wipe out all the |
|
+1 on doing globbing (I'll take care of it).
Glob can handle 2, 4, 5, so we need to handle 1 and 3. I think the best way to do this is going to be to (pseudocode): var output = [];
var results = glob(input);
for (var i = 0, len = results.length; i < len; ++i) {
if (fs.statSync(results[i]).isDirectory()) {
output.push(glob(results[i] + (options.recursive ? '/**/*' : '*')));
} else {
output.push(results[i]);
}
} |
|
I think we should not handle cases 1 and 3 in I'll write up a PR that puts a call to Edit: I accidentally referred to |
|
@nfischer: Agreed. But don't submit the PR (I've already got 75% of it). |
|
Whoops, I didn't mean to close this. Nor post that last comment. |
|
I'm going to demote this to v0.7.0, because we've got some kinks to work out. |
|
Just for future reference, this was closed in favor of #359 |
Fixes #225