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

feature: new core task for automatically running npm update/install #7

Closed
jokeyrhyme opened this issue Dec 12, 2012 · 5 comments
Closed

Comments

@jokeyrhyme
Copy link

I originally filed this request against the grunt project. I'm aware that it wasn't well-received over there, so I'm not expecting this to go very far, yet I persist...

problem

I have a typical JavaScript project. I want to automate deployment and builds to as few steps as possible. Right now I have to:

  1. git clone project
  2. git submodule init
  3. npm install
  4. grunt

It would be terrific if grunt could be configured to automatically run npm install. This seems like something everyone does over and over again, and good tools are supposed to be efficient.

This would facilitate the easy use of grunt and grunt plugins, without the extra step (provided package.json is properly defined).

alternative solutions

This can't really be done as a grunt plugin, because then it would need the developer to run npm update which defeats the purpose of this request.

I can automate this myself in a Makefile, but then why bother even using grunt then?

proposed behaviour

  • if node_modules directory does not exist, run npm install
  • if modules in packages.json->dependencies are missing from node_modules (i.e. the grunt module), run npm install

I'm not sure when it would be best to run npm update, maybe have a task option that lets the developer choose the frequency or something? This is less important for my needs than npm install, but I thought I'd mention it for completeness.

@jokeyrhyme
Copy link
Author

I just went over the workflow with a co-worker and in doing so realised just how weird it is that grunt-cli doesn't already do this.

  1. npm -g install grunt-cli
  2. npm install or npm install grunt
  3. grunt

@tkellen
Copy link
Member

tkellen commented Dec 12, 2012

I can automate this myself in a Makefile, but then why bother even using grunt then?

Are you really making the argument that you'd prefer to put your entire build process in a Makefile vs typing npm install?

I have to concur with all of Ben's reasons on gruntjs/grunt#569 for not implementing this.

The real solution you want here is to set up a post-checkout git hook.

@tkellen tkellen closed this as completed Dec 12, 2012
@jokeyrhyme
Copy link
Author

I respect your points of view (obviously it's the only mature thing to do).

I do find it weird that no-one disagrees with this point: potentially millions of people around the world are all manually running npm install. Just imagine the collective time this would save the world if just 10 more lines were added to grunt...

@tkellen
Copy link
Member

tkellen commented Dec 14, 2012

Git has a feature made for this express purpose: a post-checkout git hook. If you configured one, you could save yourself another step: you'll never have to type git submodule init again either.

If you don't want to go that route, you could always write another grunt-cli. The grunt command is barely more than 100 loc.

@jokeyrhyme
Copy link
Author

Thanks for the hints. It sounds like this exactly what I need.

<3

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

No branches or pull requests

2 participants