diff --git a/package.json b/package.json index 34a243b..29a9362 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "mkdirp": "^0.5.0", "moment": "^2.12.0", "path2": "^0.1.0", + "rimraf": "^2.6.2", "shipit-utils": "^1.1.3" } } diff --git a/tasks/deploy/fetch.js b/tasks/deploy/fetch.js index 0177481..b4f564f 100644 --- a/tasks/deploy/fetch.js +++ b/tasks/deploy/fetch.js @@ -2,6 +2,7 @@ var utils = require('shipit-utils'); var chalk = require('chalk'); var mkdirp = require('mkdirp'); var Promise = require('bluebird'); +var rimraf = require('rimraf'); /** * Fetch task. @@ -44,7 +45,7 @@ module.exports = function (gruntOrShipit) { if (shipit.config.shallowClone) { shipit.log('Deleting existing workspace "%s"', shipit.config.workspace); - return shipit.local('rm -rf ' + shipit.config.workspace) + return Promise.promisify(rimraf)(shipit.config.workspace) .then(create); } diff --git a/test/mocks/rimraf.js b/test/mocks/rimraf.js new file mode 100644 index 0000000..3af1998 --- /dev/null +++ b/test/mocks/rimraf.js @@ -0,0 +1,11 @@ +/** + * Module dependencies. + */ + +var sinon = require('sinon'); + +/** + * Expose rimraf mock. + */ + +module.exports = sinon.stub().yields(); diff --git a/test/unit/tasks/deploy/fetch.js b/test/unit/tasks/deploy/fetch.js index 572f43f..d220854 100644 --- a/test/unit/tasks/deploy/fetch.js +++ b/test/unit/tasks/deploy/fetch.js @@ -5,6 +5,7 @@ var expect = require('chai').use(require('sinon-chai')).expect; var Shipit = require('shipit-cli'); var fetchFactory = rewire('../../../../tasks/deploy/fetch'); var mkdirpMock = require('../../../mocks/mkdirp'); +var rimrafMock = require('../../../mocks/rimraf'); describe('deploy:fetch task', function () { var shipit; @@ -59,7 +60,7 @@ describe('deploy:fetch task', function () { shipit.start('deploy:fetch', function (err) { if (err) return done(err); - expect(shipit.local).to.be.calledWith('rm -rf /tmp/workspace'); + expect(rimrafMock).to.be.calledWith('/tmp/workspace'); expect(mkdirpMock).to.be.calledWith('/tmp/workspace'); expect(shipit.local).to.be.calledWith('git init', {cwd: '/tmp/workspace'}); expect(shipit.local).to.be.calledWith('git remote', {cwd: '/tmp/workspace'});