Skip to content

Commit

Permalink
Merge cedb76c into dcad8b5
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDancingCode committed Nov 11, 2019
2 parents dcad8b5 + cedb76c commit ec81606
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 15 deletions.
8 changes: 4 additions & 4 deletions index.js
@@ -1,6 +1,6 @@
'use strict';

const frontMatter = require('front-matter');
const matter = require('gray-matter');
const inspectWithKind = require('inspect-with-kind');
const objectPath = require('object-path');
const PluginError = require('plugin-error');
Expand Down Expand Up @@ -31,8 +31,8 @@ module.exports = function gulpFrontMatter(...args) {
let content;

try {
content = frontMatter(String(buf), {filename: file.path});
objectPath.set(file, options.property, content.attributes);
content = matter(String(buf), {filename: file.path});
objectPath.set(file, options.property, content.data);
} catch (err) {
err.message = err.stack.replace(/\n +at[\s\S]*/u, '');
const errorOption = {};
Expand All @@ -46,7 +46,7 @@ module.exports = function gulpFrontMatter(...args) {
}

if (options.remove !== false) {
done(null, Buffer.from(content.body));
done(null, Buffer.from(content.content));
return;
}

Expand Down
77 changes: 68 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -32,7 +32,7 @@
"meta-data"
],
"dependencies": {
"front-matter": "^2.3.0",
"gray-matter": "^4.0.1",
"inspect-with-kind": "^1.0.4",
"object-path": "^0.11.4",
"plugin-error": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion test.js
Expand Up @@ -102,7 +102,7 @@ test('gulp-front-matter', t => {
/.*line.*column/u.test(message),
'should emit a plugin error when it cannot parse front matter in a buffer as YAML.'
);
t.equal(fileName, 'foo/bar.yaml', 'should include file name in the error.');
t.ok(/^foo(\\|\/)bar\.yaml$/u.test(fileName), 'should include file name in the error.');
})
.end(new File({
path: 'foo/bar.yaml',
Expand Down

0 comments on commit ec81606

Please sign in to comment.