Skip to content

Commit

Permalink
Merge pull request #66 from elliottsj/renovate/webpack-5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottsj authored Oct 18, 2020
2 parents 89b4c9c + cf0c516 commit 7622cd8
Show file tree
Hide file tree
Showing 7 changed files with 214 additions and 1,227 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm install --global yarn@1
- run: yarn install
- run: yarn test
- run: npm test
5 changes: 4 additions & 1 deletion example/example.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ const config = require('./webpack.config');
test('extracts frontmatter and body as an object', () =>
new Promise((resolve) => {
webpack(config, (error, stats) => {
if (error) {
throw error;
}
const bundlePath = path.resolve(
stats.compilation.compiler.outputPath,
stats.toJson().assetsByChunkName.main
stats.toJson().assetsByChunkName.main[0]
);
expect(require(bundlePath)).toMatchInlineSnapshot(`
Object {
Expand Down
2 changes: 1 addition & 1 deletion example/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
rules: [
{
test: /\.md$/,
loaders: ['json-loader', frontMatterLoader],
use: ['json-loader', frontMatterLoader],
},
],
},
Expand Down
3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
'use strict';

var loaderUtils = require('loader-utils');
var fm = require('front-matter');

module.exports = function (source) {
this.cacheable && this.cacheable();
var options = loaderUtils.getOptions(this) || {};
var options = this.getOptions() || {};

var frontmatter = fm(source);
if (options.onlyAttributes) {
Expand Down
6 changes: 3 additions & 3 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Here is some example content`;
test('extracts frontmatter and body as an object', () => {
const context = {
cacheable: jest.fn(),
query: '',
getOptions: () => ({}),
};

expect(frontMatterLoader.call(context, source)).toBe(
Expand All @@ -29,7 +29,7 @@ test('extracts frontmatter and body as an object', () => {
test('extracts only the frontmatter when onlyAttributes is passed', () => {
const context = {
cacheable: jest.fn(),
query: '?onlyAttributes',
getOptions: () => ({ onlyAttributes: true }),
};

expect(frontMatterLoader.call(context, source)).toBe(
Expand All @@ -40,7 +40,7 @@ test('extracts only the frontmatter when onlyAttributes is passed', () => {
test('extracts only the body when onlyBody is passed', () => {
const context = {
cacheable: jest.fn(),
query: '?onlyBody',
getOptions: () => ({ onlyBody: true }),
};

expect(frontMatterLoader.call(context, source)).toBe(
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@
},
"homepage": "https://github.com/elliottsj/front-matter-loader#readme",
"dependencies": {
"front-matter": "^4.0.0",
"loader-utils": "^2.0.0"
"front-matter": "^4.0.0"
},
"devDependencies": {
"jest": "26.5.3",
"json-loader": "0.5.7",
"prettier": "2.1.2",
"webpack": "4.44.1"
"webpack": "5.1.3"
},
"jest": {
"testEnvironment": "node"
Expand Down
Loading

0 comments on commit 7622cd8

Please sign in to comment.