Skip to content

Breaking: Allow -- as args separators (fixes #188)#207

Merged
arturadib merged 1 commit intoshelljs:masterfrom
nzakas:issue188
May 19, 2015
Merged

Breaking: Allow -- as args separators (fixes #188)#207
arturadib merged 1 commit intoshelljs:masterfrom
nzakas:issue188

Conversation

@nzakas
Copy link
Copy Markdown
Contributor

@nzakas nzakas commented May 15, 2015

This implements a change that allows -- to indicate arguments to be passed to make targets. Basically, you can do this:

target.foo = function(args) {

};

And args will be everything after the -- on the command line, so for example:

$ node Makefile.js foo -- bar baz

args in the previous code will be ['bar', 'baz'].

I noticed there's a force argument for targets, but I couldn't find anywhere it's documented or used. So, I moved it to be the second argument as it seems mostly unused at the moment.

Other caveats:

  1. It appears there aren't any tests for make.js, so I didn't know if it's okay to just make changes. I did test it locally with an example file and it worked
  2. npm test fails for me (I'm on Windows using Git Bash) and I couldn't figure out how to get it to run, so I'm not really sure about this change.

@arturadib let me know if this is okay or if you'd like other changes.

make.js Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this comment was meant to go right above the setTimeout below, otherwise it's puzzling :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops!

@arturadib
Copy link
Copy Markdown
Collaborator

OK, so it just occurred to me that some folks (including one of our largest users, PDF.js) pass arguments directly to targets from within the script itself, see e.g. https://github.com/mozilla/pdf.js/blob/master/make.js#L473.

I don't think this would break things for them unless they started using the new -- feature, but just wanted to give a heads-up in case I'm missing something. /cc @yurydelendik @brendandahl

If the PDF.js folks are OK with this let's 🐑 it!

@nzakas
Copy link
Copy Markdown
Contributor Author

nzakas commented May 16, 2015

It would break right now because I'm always passing an empty array if -- isn't used. If instead I passed undefined, then it seems like it would be backwards compatible.

@nzakas
Copy link
Copy Markdown
Contributor Author

nzakas commented May 17, 2015

That's not how it works. The -- is separate, such as:

$ node Makefile.js test -- tests/lib/too.js tests/lib/bar.js

@arturadib
Copy link
Copy Markdown
Collaborator

If instead I passed undefined, then it seems like it would be backwards compatible.

Cool, can we try that?

@nzakas
Copy link
Copy Markdown
Contributor Author

nzakas commented May 18, 2015

Updated.

@arturadib
Copy link
Copy Markdown
Collaborator

Merging this in. @brendandahl @yurydelendik please let me know if this breaks the build for PDF.js!

arturadib added a commit that referenced this pull request May 19, 2015
Breaking: Allow -- as args separators (fixes #188)
@arturadib arturadib merged commit d48ecc3 into shelljs:master May 19, 2015
@arturadib
Copy link
Copy Markdown
Collaborator

this is now in shelljs@0.5.0

@nzakas
Copy link
Copy Markdown
Contributor Author

nzakas commented May 19, 2015

Yay, thanks!

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.

2 participants