Skip to content

Commit

Permalink
Fix empty files leading to no realSrc and error in output.js
Browse files Browse the repository at this point in the history
  • Loading branch information
arrowrowe committed Oct 17, 2015
1 parent 6a500e8 commit 970d7de
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/file/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ var path = require('path');
// It does not return. The argument `commands` will change.
module.exports = function (assets, pkg, commands) {

if (commands.length === 0) {
return;
}

var srcLength = pkg.realSrc.length;
var pkgDist = pkg.dist || pkg.name;
var dist = path.resolve(assets.dist, pkgDist);
Expand Down
15 changes: 15 additions & 0 deletions test/lib/file/output-spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var utilOutput = require('../../../lib/file/output');
var expect = require('chai').expect;
var sinon = require('sinon');

describe('lib/file/output', function () {

Expand Down Expand Up @@ -77,4 +78,18 @@ describe('lib/file/output', function () {
}).to.throw('Unrecognized behavior [whatever]!');
});

it('does nothing if no commands provided', function () {
var spy = sinon.spy();
utilOutput({
dist: '/fake'
}, {
name: 'fake',
realSrc: ''
}, {
length: 0,
forEach: spy
});
expect(spy.callCount).to.equal(0);
});

});

0 comments on commit 970d7de

Please sign in to comment.