-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 bin into local grunt #943
Comments
I agree with this. It would be really interesting this feature. 👍 |
@shama and me had an IRC discussion regarding this. A few reasons for this:
If can add this Q: Why not just install grunt-cli locally? @cowboy thoughts? (also see TryGhost/Ghost#1053 ) There could be different ways to achieve this functionality, peer dependency was a rough idea. (also really happy to see that @chrisenytc is interested in this feature) |
Ok. I really like the idea of the grunt lib including a barebones bin for idiomatic Node.js Keep in mind that we'll have to tell people they have a few ways of running Grunt:
Notes:
Other possible caveats here:
Does the grunt #!/usr/bin/env node
'use strict';
require('../lib/grunt').cli(); |
I just tested this on both v0.8 and v0.10. If grunt-cli is locally and globally installed, typing
AFAIK, this is unavoidable. Even with the current way grunt is built, people can place any module into a global or semi-global folder and node will find it: http://nodejs.org/api/modules.html#modules_loading_from_node_modules_folders Maybe a note on the getting started guide instructing people to avoid global setups would be a good idea. |
It is possible to detect that a module is being installed globally & force it to fail. I've never seen it in the wild, but it can be done. |
Maybe a |
we had a pre-install script for a few seconds that did this: if (process.env.npm_config_global === 'true') {
console.error('###################################################################\n');
console.error('Please use `npm install -g grunt-cli` to install the grunt command.');
console.error('Grunt itself must be defined as a local dependency of your project.');
console.error('For more information, read this: http://bit.ly/fyW0Fo\n');
console.error('###################################################################\n');
process.exit(1);
} |
I wish @isaacs could weigh in on this. |
Method 1 is for beginners and basic usage. 2,3,4 are advanced / custom usages
If there are not edge cases to this, then this sounds good
@tkellen's script should take care of it. It might make sense to be able to force it, but I'm not sure why would anyone really need to have it globally. The goal here is to prevent mistakes for those who don't read the install docs.
What migration though? Local CLI should be a feature that doesn't affect the current global CLI setups in any way
👍 |
@vladikoff some people have already installed grunt-cli locally beside grunt, even though it is not supported. Those people will need to remove grunt-cli from their project. It's not something we support, but I believe enough people do it that it warrants an explanation in a migration guide. |
Because adding a bin to grunt will cause errors when |
Huge 👍 |
If you make |
Hah, ignore me, that's basically what @shama said in the OP. Signing off now! |
+1 would like to see this land. Seems weird to install grunt-cli in my package deps. |
@JKAussieSkater this is gonna be a change for the "docs" if #1438 lands, for your information. |
This is done on fb9dd08. When |
@vladikoff, noted! |
Reference TryGhost/Ghost#1053
I think it would be nice if
npm install grunt
included a bin script. Then Grunt users could recommendnpm install && npm test
without explaining the additional step to install the grunt cli globally and have the package dependencies completely self contained.@vladikoff had the good idea of just adding
grunt-cli
as a peer dependency to Grunt.The current solution is to
npm install grunt-cli
locally and reference in the package.json with:in which npm will find the local
node_modules/.bin/grunt
binary installed by grunt-cli.I think at the very least, this message https://github.com/gruntjs/grunt-cli#installing-grunt-cli-locally should be removed and a completely local install method should be officially supported.
The text was updated successfully, but these errors were encountered: