2013-07-05 97 views

回答

14

要麼建立在你的package.json一個npm postinstall script

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

或者使用grunt-shell執行命令克隆回購:

grunt.initConfig({ 
    shell: { 
     gitclone: { 
      command: 'git clone git://github.com/facebook/xctool.git' 
     } 
    } 
}); 
+1

grunt-shell確實幫助我解決了我在這個Gruntfile中遇到的其他問題(例如http://stackoverflow.com/questions/16711058/running-a-grunt-task-on-one-gruntfile-from-another) 。非常感謝您的插件! – xverges

+2

僅供參考:您的'initConfig'對象缺少一個右大括號(特別是'shell'屬性對象)。所以SO不會讓我做出改變,因爲它最少有6個字符用於編輯。 –

2

您是否知道npm install支持git網址?

npm install git://github.com/facebook/xctool.git 

Docs

+1

感謝。我沒有意識到這一點。不幸的是,先決條件回購並不是一個包含package.json文件的模塊,而是與node.js完全無關的東西。 npm對此並不滿意。 – xverges

4

有現在是這個Grunt插件。不確定當時是否可用。我仍然有一些問題得到它的工作。

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

gitclone: 
    clone: 
    options: 
     repository: "https://github.com/imaginethepoet/autojqm" 
     branch: "master" 
     directory: "repo"