Skip to content

Commit

Permalink
Make using ssh optional during clone, default is to just use whatever…
Browse files Browse the repository at this point in the history
… is in the config files. (git://)
  • Loading branch information
mikenairn committed May 15, 2017
1 parent 905ce25 commit 8d2bc7c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tasks/clone.js
Expand Up @@ -6,15 +6,15 @@ module.exports = function(grunt) {
var templateHelper = require('./lib/templateHelper').init(grunt);
var _ = require('underscore');

function cloneAppTemplates(filepath, cloneDepth) {
function cloneAppTemplates(filepath, cloneDepth, useSsh) {
grunt.config.set('gitclone', {});

var globalJson = grunt.file.readJSON(filepath);

templateHelper.walkObjects(globalJson.show, function (obj) {
var prefix = 'gitclone.' + obj.id + '.options';
if (_.has(obj, 'repoUrl') && _.has(obj, 'repoBranch')) {
var repoUrl = obj.repoUrl.replace('git://github.com/','git@github.com:');
var repoUrl = useSsh ? obj.repoUrl.replace('git://github.com/','git@github.com:') : obj.repoUrl;
grunt.config.set(prefix + '.directory', 'tmp/' + obj.id);
grunt.config.set(prefix + '.repository', repoUrl);
grunt.config.set(prefix + '.branch', obj.repoBranch.split('/').pop());
Expand All @@ -30,8 +30,9 @@ module.exports = function(grunt) {

grunt.registerMultiTask('clone', 'Clone all defined app repos', function () {
var cloneDepth = grunt.option('clone-depth') || 1;
var useSsh = grunt.option('use-ssh');
this.filesSrc.forEach(function (filepath) {
cloneAppTemplates(filepath, cloneDepth);
cloneAppTemplates(filepath, cloneDepth, useSsh);
});
});

Expand Down

0 comments on commit 8d2bc7c

Please sign in to comment.