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 gulp.requireNodeFlags #1535

Closed
wants to merge 1 commit into from
Closed

Conversation

rhendric
Copy link

This is a work in progress; I'd want to add documentation and tests but I wanted to toss the basic idea out there to see if there's heavy pushback first.

This provides a way for a gulpfile or a gulp plugin to specify that it requires special Node.js flags (like --harmony_proxies). Adding gulp.requireNodeFlags('--harmony_proxies', ...) to the top of a gulpfile is all that's required. It reuses the same respawn code that gets used currently when using Node.js flags as arguments to gulp, so instead of getting an error message if you forget to invoke gulp with the right things, gulp just quietly restarts with the missing flags added.

I'm torn on whether requireNodeFlags should go here or in gulp-utils; the latter feels slightly more correct if I expect plugins and not just gulpfiles to use this, but then I'd have two PRs to wrangle so I figured I'd get confirmation on that from you all first.

Feedback please?

@phated
Copy link
Member

phated commented Feb 25, 2016

You can just do this in your gulpfile. Check process.argv and throw if it doesn't exist.

@phated phated closed this Feb 25, 2016
@rhendric
Copy link
Author

No, that just fails the process with an error. What I'm proposing here restarts gulp with the missing flags.

@phated
Copy link
Member

phated commented Feb 25, 2016

3.x is API locked and we aren't inclined in expanding the 4.0 API surface, as it is nearing completion. This would be something that would have to be handled by gulp-cli but I don't think it has a wide enough use case to warrant adding it.

@rhendric
Copy link
Author

If you're not willing to take the whole feature, is there a hook or something you'd be willing to add to gulp-cli to enable shutting gulp down gracefully? I can do just about all of this respawning stuff from a user library; the only missing piece is some way to stop gulp's main load-and-run process without literally process.exiting or dumping a bunch of error noise to console.

Just some kind of try/catch around require(env.configPath) that returns silently as long as the error caught meets some condition would be enough for me—it doesn't have to know about missing flags, just check for an interruptGulp property or something. Or something else that achieves that goal; it doesn't have to be error catching. I totally understand wanting to keep a hard line against API bloat, but can you help me out at all? Without something like this, it's basically unfeasible to make gulp plugins that depend on in-progress Node.js features, because approximately zero people are going to want to call gulp --harmony-proxies every time they want to build.

@phated
Copy link
Member

phated commented Feb 25, 2016

@rhendric definitely willing to discuss things but your example of writing plugins that use this new API doesn't seem to make sense because gulp plugins aren't supposed to require gulp as a dependency. Willing to brainstorm but I think it needs to be some subset of your ideas and I'm not sure how to handle it. Could you open an issue on the gulp-cli repo since it will absolutely have to go there if we solve it.

@rhendric
Copy link
Author

Will do, 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