Skip to content

Commit

Permalink
feat: Add template filename to PluginError (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Jun 9, 2021
1 parent 42f8087 commit cfaad8c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Expand Up @@ -21,7 +21,7 @@ module.exports = function gulpPug(options) {

vinylContents(file, function onContents(err, contents) {
if (err) {
return cb(new PluginError('gulp-pug', err));
return cb(new PluginError('gulp-pug', err, { fileName: opts.filename }));
}

if (!contents) {
Expand All @@ -41,7 +41,7 @@ module.exports = function gulpPug(options) {
}
file.contents = Buffer.from(compiled);
} catch (err) {
return cb(new PluginError('gulp-pug', err));
return cb(new PluginError('gulp-pug', err, { fileName: opts.filename }));
}

cb(null, file);
Expand Down
1 change: 1 addition & 0 deletions test/error.js
Expand Up @@ -10,6 +10,7 @@ describe('error', function () {
it('should emit errors of pug correctly', function (done) {
pipe([from.obj([getFixture('pug-error.pug')]), task(), concat()], (err) => {
expect(err).toBeInstanceOf(PluginError);
expect(err.fileName).toMatch('pug-error.pug');
done();
});
});
Expand Down

0 comments on commit cfaad8c

Please sign in to comment.