Skip to content

Commit

Permalink
Merge pull request #16 from DataDog/yoann/fix-output-hook
Browse files Browse the repository at this point in the history
Fix renderer hook
  • Loading branch information
yoannmoinet authored Sep 17, 2020
2 parents bd4f601 + 98f74d1 commit 43d7f28
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@datadog/build-plugin",
"version": "0.3.1",
"version": "0.3.2",
"license": "MIT",
"author": "Datadog",
"repository": "git://github.com/DataDog/build-plugin.git",
Expand Down
6 changes: 6 additions & 0 deletions src/hooks/__tests__/outputFiles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('Output Files', () => {
// Cleaning
await Promise.all(getRemoveProms(output));
});

test('It should allow a relative path', async () => {
// Relative path
const output = './test2/';
Expand All @@ -57,4 +58,9 @@ describe('Output Files', () => {
// Cleaning
await Promise.all(getRemoveProms(path.join(__dirname, output)));
});

test('It should export hooks', () => {
const outputFiles = require('../outputFiles');
expect(typeof outputFiles.hooks).toBe('object');
});
});
7 changes: 6 additions & 1 deletion src/hooks/__tests__/renderer.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('Renderer', () => {
test('it should outputGenerals the same with Webpack 5 and 4', () => {
test('It should outputGenerals the same with Webpack 5 and 4', () => {
const { outputGenerals } = require('../renderer');

const ar = [{ name: 'element1' }, { name: 'element2' }];
Expand Down Expand Up @@ -41,4 +41,9 @@ describe('Renderer', () => {

expect(outputWebpack4).toBe(outputWebpack5);
});

test('It should export hooks', () => {
const renderer = require('../renderer');
expect(typeof renderer.hooks).toBe('object');
});
});
5 changes: 5 additions & 0 deletions src/hooks/datadog/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ describe('Datadog Hook', () => {

expect(typeof obj).toBe('object');
});

test('It should export hooks', () => {
const datadog = require('../index');
expect(typeof datadog.hooks).toBe('object');
});
});
8 changes: 3 additions & 5 deletions src/hooks/datadog/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ const postoutput = async function postoutput(
return { metrics };
};

module.exports = {
hooks: {
preoutput,
postoutput,
},
export const hooks = {
preoutput,
postoutput,
};
2 changes: 1 addition & 1 deletion src/hooks/outputFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ const output = async function output(this: BuildPlugin, { report, metrics, stats
}
};

module.exports = { hooks: { output } };
export const hooks = { output };
20 changes: 9 additions & 11 deletions src/hooks/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,14 @@ const outputModules = (times: ResultModules, deps: LocalModules) => {
render(modulesPerTime, (module) => formatDuration(module.duration));
};

export default {
hooks: {
async output(this: BuildPlugin, { report, stats }: HooksContext) {
if (this.options.output === false) {
return;
}
outputTapables(report.timings.tapables);
outputLoaders(report.timings.loaders);
outputModules(report.timings.modules, report.dependencies);
outputGenerals(stats);
},
export const hooks = {
async output(this: BuildPlugin, { report, stats }: HooksContext) {
if (this.options.output === false) {
return;
}
outputTapables(report.timings.tapables);
outputLoaders(report.timings.loaders);
outputModules(report.timings.modules, report.dependencies);
outputGenerals(stats);
},
};

0 comments on commit 43d7f28

Please sign in to comment.