From cfaad8c5d6923d6c15f824ae717c5f0d16fc7490 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Tue, 8 Jun 2021 21:01:26 -0700 Subject: [PATCH] feat: Add template filename to PluginError (#220) --- index.js | 4 ++-- test/error.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 229c0a2..608e536 100644 --- a/index.js +++ b/index.js @@ -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) { @@ -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); diff --git a/test/error.js b/test/error.js index e0097f1..4f7e68b 100644 --- a/test/error.js +++ b/test/error.js @@ -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(); }); });