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

Commit e705d66

Browse files
committed
Use rimraf for cross platform compatibility
1 parent 1f5a9f8 commit e705d66

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"mkdirp": "^0.5.0",
4646
"moment": "^2.12.0",
4747
"path2": "^0.1.0",
48+
"rimraf": "^2.6.2",
4849
"shipit-utils": "^1.1.3"
4950
}
5051
}

tasks/deploy/fetch.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ var utils = require('shipit-utils');
22
var chalk = require('chalk');
33
var mkdirp = require('mkdirp');
44
var Promise = require('bluebird');
5+
var rimraf = require('rimraf');
56

67
/**
78
* Fetch task.
@@ -44,7 +45,7 @@ module.exports = function (gruntOrShipit) {
4445

4546
if (shipit.config.shallowClone) {
4647
shipit.log('Deleting existing workspace "%s"', shipit.config.workspace);
47-
return shipit.local('rm -rf ' + shipit.config.workspace)
48+
return Promise.promisify(rimraf)(shipit.config.workspace)
4849
.then(create);
4950
}
5051

test/mocks/rimraf.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Module dependencies.
3+
*/
4+
5+
var sinon = require('sinon');
6+
7+
/**
8+
* Expose rimraf mock.
9+
*/
10+
11+
module.exports = sinon.stub().yields();

test/unit/tasks/deploy/fetch.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var expect = require('chai').use(require('sinon-chai')).expect;
55
var Shipit = require('shipit-cli');
66
var fetchFactory = rewire('../../../../tasks/deploy/fetch');
77
var mkdirpMock = require('../../../mocks/mkdirp');
8+
var rimrafMock = require('../../../mocks/rimraf');
89

910
describe('deploy:fetch task', function () {
1011
var shipit;
@@ -59,7 +60,7 @@ describe('deploy:fetch task', function () {
5960

6061
shipit.start('deploy:fetch', function (err) {
6162
if (err) return done(err);
62-
expect(shipit.local).to.be.calledWith('rm -rf /tmp/workspace');
63+
expect(rimrafMock).to.be.calledWith('/tmp/workspace');
6364
expect(mkdirpMock).to.be.calledWith('/tmp/workspace');
6465
expect(shipit.local).to.be.calledWith('git init', {cwd: '/tmp/workspace'});
6566
expect(shipit.local).to.be.calledWith('git remote', {cwd: '/tmp/workspace'});

0 commit comments

Comments
 (0)