diff --git a/tasks/deploy/fetch.js b/tasks/deploy/fetch.js index c82f2b0..78aca69 100644 --- a/tasks/deploy/fetch.js +++ b/tasks/deploy/fetch.js @@ -36,12 +36,21 @@ module.exports = function (grunt) { */ function createWorkspace(cb) { - grunt.log.writeln('Create workspace "%s"', grunt.shipit.config.workspace); - mkdirp(grunt.shipit.config.workspace, function (err) { - if (err) return cb(err); - grunt.log.oklns('Workspace created.'); - cb(); - }); + function createWorkspace() { + grunt.log.writeln('Create workspace "%s"', grunt.shipit.config.workspace); + mkdirp(grunt.shipit.config.workspace, function (err) { + if (err) return cb(err); + grunt.log.oklns('Workspace created.'); + cb(); + }); + } + + if (grunt.shipit.config.shallowClone) { + grunt.log.writeln('Deleting existing workspace "%s"', grunt.shipit.config.workspace); + grunt.shipit.local('rm -rf ' + grunt.shipit.config.workspace, createWorkspace); + } else { + createWorkspace(); + } } /** diff --git a/test/unit/tasks/deploy/fetch.js b/test/unit/tasks/deploy/fetch.js index eb12f13..cf93a46 100644 --- a/test/unit/tasks/deploy/fetch.js +++ b/test/unit/tasks/deploy/fetch.js @@ -66,6 +66,7 @@ describe('deploy:fetch task', function () { runTask('deploy:fetch', function (err) { if (err) return done(err); + expect(grunt.shipit.local).to.be.calledWith('rm -rf /tmp/workspace'); expect(mkdirpMock).to.be.calledWith('/tmp/workspace'); expect(grunt.shipit.local).to.be.calledWith('git init', {cwd: '/tmp/workspace'}); expect(grunt.shipit.local).to.be.calledWith('git remote', {cwd: '/tmp/workspace'});