Selectively use Gulp instead of Grunt with different package.json files

I think I already know the answer to this question based on what I’ve read online, but maybe someone out there has a clever solution (even if it ends up being a bash script I can run), but I work on a team that is using grunt as a build tool and the watch/compile/reload step takes far too long (on the order of 4-5 seconds for a single stylus edit). I rewrote the gruntfile using gulp and mine takes under 10 ms for any edit, be it JS, stylus, or html. Needless to say, I want to use mine, but the other guys don’t. I’m currently using the gulp-load-plugins module which requires that my package.json file has all the gulp plugins listed, which can’t be checked in. Currently, I have a package.json file outside of the project and whenever I want to work, I rename the existing package.json containing the grunt plugins, move mine into the project, do my work, and then move it out, rename the old, and then commit. It’s not terribly painful, but is there a better way? I’d like to keep the discussion on-topic to “selectively using grunt vs gulp with different package.json files” and not be told that I should talk with my team to normalize what we use. If there isn’t a direct solution, it’d be awesome if one of you shell scripters out there could help me write a simple function that will either mv package.json to package.json.bak and copy my version in, or rm mine and mv package.json.bak to package.json, depending on what state I’m in. I made a few attempts, but I’m pretty shell-dumb and haven’t been successful. Thanks in advance!


If a shell script is the way to go, what do you guys think of this?

gulpy() {
  if [ -e package.json.bak ] # this means I'm currently in "my" state
    rm package.json # remove my file
    mv package.json.bak package.json # rename "their" file to what git knows about
    mv package.json package.json.bak # rename "their" file so I can copy mine in
    cp ../package.json . # copy mine in

It works so I guess I don’t really need an opinion on it, but I thought I’d share. I doubt too many others are in this predicament, but this is my current solution.

Source: shell

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.