Skip to content
This repository has been archived by the owner on Mar 18, 2018. It is now read-only.

Commit

Permalink
Use rimraf for cross platform compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
pbarbiero committed Oct 25, 2017
1 parent 1f5a9f8 commit e705d66
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
3 changes: 2 additions & 1 deletion tasks/deploy/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}

Expand Down
11 changes: 11 additions & 0 deletions test/mocks/rimraf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Module dependencies.
*/

var sinon = require('sinon');

/**
* Expose rimraf mock.
*/

module.exports = sinon.stub().yields();
3 changes: 2 additions & 1 deletion test/unit/tasks/deploy/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'});
Expand Down

0 comments on commit e705d66

Please sign in to comment.