Skip to content

Commit

Permalink
Fixes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
ritch authored and raymondfeng committed Oct 24, 2018
1 parent b0383c4 commit 07c1ccc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
22 changes: 13 additions & 9 deletions examples/strong-docs/lib/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,20 @@ Docs.prototype.parse = function (fn) {
files[f] = contents;
});

matchedFiles.forEach(function (p) {
if(typeof p === 'string') {
var f = path.join(root || cwd, p);
if(self.hasExt(f)) {
te.task(fs, 'readFile', f, 'utf8');
} else {
te.task(fs, 'stat', f);
if(matchedFiles.length) {
matchedFiles.forEach(function (p) {
if(typeof p === 'string') {
var f = path.join(root || cwd, p);
if(self.hasExt(f)) {
te.task(fs, 'readFile', f, 'utf8');
} else {
te.task(fs, 'stat', f);
}
}
}
}.bind(this));
}.bind(this));
} else {
te.emit('error', new Error('no matching files were found'));
}
}

Docs.prototype.hasExt = function (f) {
Expand Down
11 changes: 11 additions & 0 deletions examples/strong-docs/test/docs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ describe('Docs', function() {
});
});

it('should error when a file does not exist', function (done) {
Docs.parse({
content: ['does-not-exist'],
root: __dirname
}, function (err, docs) {
assert(err);
assert.equal(err.message, 'no matching files were found');
done();
});
});

describe('util', function() {
describe('.encodeAnchor(str)', function() {
it('should create url safe anchor names', function () {
Expand Down

0 comments on commit 07c1ccc

Please sign in to comment.