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

Commit

Permalink
Merge pull request #486 from duojs/fix/empty-input-string
Browse files Browse the repository at this point in the history
Fixing empty entry source string
  • Loading branch information
dominicbarnes committed Jul 22, 2015
2 parents 87cb70d + 0a32f96 commit b961dc9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lib/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@ File.prototype.dependencies = function () {
*/

File.prototype.load = function *() {
if (this.src) return this;
if (typeof this.src !== 'undefined') return this;

// read the file
this.attrs.src = this.raw = this.raw
|| (yield fs.readFile(this.path, 'utf8'));
var raw = this.raw;
if (raw == null) raw = yield fs.readFile(this.path, 'utf8');
this.attrs.src = raw;

// transform the file and update attributes
var entry = this.entry ? this : this.duo.entry();
Expand All @@ -124,7 +125,7 @@ File.prototype.load = function *() {
*/

File.prototype.exists = function *() {
if (this.raw) return true;
if (this.raw != null) return true;
else return yield exists(this.path);
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"coffee-script": "^1.9.3",
"duo-jade": "0.x",
"eslint": "^0.23.0",
"eslint-config-duo": "0.0.1",
"eslint-config-duo": "0.0.4",
"expect.js": "^0.3.1",
"gnode": "^0.1.1",
"gulp": "^3.9.0",
Expand Down
4 changes: 4 additions & 0 deletions test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@ describe('Duo API', function () {
assert.equal(ctx.b, 'b');
assert.equal(ctx.c, 'c');
});

it('should not fail when the input source code is empty', function *() {
yield Duo(path('simple')).entry('', 'css').run();
});
});

// describe('with .development(false)');
Expand Down

0 comments on commit b961dc9

Please sign in to comment.