Skip to content

Commit

Permalink
fix: generated loader template
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Aug 1, 2020
1 parent 319e2c4 commit f99d897
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/generate-loader/templates/src/_index.js.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* https://webpack.js.org/contribute/writing-a-loader
*/

export default function loader(source) {
module.exports = function loader(source) {
const { loaders, resource, request, version, webpack } = this;

console.log('<%= name %>');
const newSource = `
/**
* <%= name %>
Expand Down
6 changes: 5 additions & 1 deletion test/loader/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('loader command', () => {
});

it('should scaffold loader template with a given name', async () => {
const { stdout } = await runPromptWithAnswers(__dirname, ['loader'], [`${loaderName}${ENTER}`]);
let { stdout } = await runPromptWithAnswers(__dirname, ['loader'], [`${loaderName}${ENTER}`]);

expect(stdout).toContain(firstPrompt);

Expand All @@ -46,5 +46,9 @@ describe('loader command', () => {
files.forEach((file) => {
expect(existsSync(join(__dirname, `${loaderName}/${file}`))).toBeTruthy();
});

//check if the the generated plugin works successfully
stdout = run(__dirname, ['--config', './test-loader/examples/simple/webpack.config.js'], false).stdout;
expect(stdout).toContain('test-loader');
});
});

0 comments on commit f99d897

Please sign in to comment.