Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grunt task to clone/checkout a git project

Tags:

npm

gruntjs

I'm working on a project that is built using grunt. It depends on an external repo (https://github.com/facebook/xctool) that I would like to clone/pull during npm install or grunt mySetupTask.

I've seen trails of a grunt-gitco plugin at http://gruntjs.com/plugins/checkout, but it does not seem to be available.

Any good starting point for this?

like image 936
xverges Avatar asked Jul 05 '13 05:07

xverges


2 Answers

Either set up a npm postinstall script in your package.json:

{
    "name": "mypackage",
    "scripts": {
        "postinstall": "git clone git://github.com/facebook/xctool.git"
    }
}

Or use grunt-shell to execute the command to clone the repo:

grunt.initConfig({
    shell: {
        gitclone: {
            command: 'git clone git://github.com/facebook/xctool.git'
        }
    }
});
like image 179
Sindre Sorhus Avatar answered Nov 15 '22 21:11

Sindre Sorhus


There is now a Grunt plugin for this. Not sure if it was available at the time. I'm still having some issues getting it working.

https://npmjs.org/package/grunt-git

gitclone:
  clone:
    options:
      repository: "https://github.com/imaginethepoet/autojqm"
      branch: "master"
      directory: "repo"
like image 26
imaginethepoet Avatar answered Nov 15 '22 22:11

imaginethepoet