Skip to content

feat(glob): glob support for (almost) all commands#352

Merged
ariporad merged 1 commit intomasterfrom
glob-all-commands
Feb 14, 2016
Merged

feat(glob): glob support for (almost) all commands#352
ariporad merged 1 commit intomasterfrom
glob-all-commands

Conversation

@nfischer
Copy link
Copy Markdown
Member

Fixes #343. This performs glob expansion on commands, where it makes sense. This doesn't glob for:

  • pwd() (it doesn't take any arguments)
  • test() (globbing here is very unreliable in bash)
  • exec() (this actually does glob-expand, but that's done in the shell itself (/bin/sh), not by this function
  • set() (globbing doesn't make sense)
  • tempdir() (it doesn't take any arguments)

Some other commands we might want to not permit to glob (because it isn't useful, and I suspect globbing slightly hampers performance) would be:

  • which()
  • mkdir()

I had to modify some test cases that didn't actually have correct behavior (the ls('path/*') cases were often wrong). I also added a lot of new test cases for globs on commands that didn't previously have them.

I think this should be merged before #275, because it will help make sure that glob.sync doesn't break behavior.

@nfischer nfischer added this to the v0.7.0 milestone Feb 11, 2016
src/common.js Outdated
function wrap(cmd, fn, options) {
// -1 means "don't glob"
// 0 means "glob the options" (probably don't want this)
var indexOfExpandableArg = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be passed in as an option to common.wrap.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, I was thinking about that approach as well. It's probably cleaner, so I'll modify it to do that instead. I'll get rid of the -1 stuff too.

@ariporad
Copy link
Copy Markdown
Contributor

One nitpick, otherwise is good!

@nfischer nfischer force-pushed the glob-all-commands branch 2 times, most recently from 4d0e0e9 to 02324f6 Compare February 11, 2016 09:30
@nfischer
Copy link
Copy Markdown
Member Author

@ariporad This should have your comments resolved. What do you think about globbing for which() and mkdir()? If we want to support these, then we should probably make unit tests for them. Otherwise, I can remove globbing support for them.

Also, I'll probably add something about "globbing is supported for all commands"

@ariporad
Copy link
Copy Markdown
Contributor

@nfischer: Yes for mkdir, no for which.

@nfischer
Copy link
Copy Markdown
Member Author

@ariporad which() does not glob, and mkdir() does glob. This should be ready for review

@ariporad
Copy link
Copy Markdown
Contributor

LGTM!

ariporad added a commit that referenced this pull request Feb 14, 2016
feat(glob): glob support for (almost) all commands
@ariporad ariporad merged commit 3ebfe1a into master Feb 14, 2016
@ariporad ariporad deleted the glob-all-commands branch February 14, 2016 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants