Skip to content

Commit 71a4153

Browse files
authored
Merge pull request #104 from webpack/feature/name
give all constructors a name argument
2 parents e225fba + 51eec78 commit 71a4153

13 files changed

+32
-25
lines changed

lib/AsyncParallelBailHook.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ const COMPILE = function(options) {
7171
return factory.create(options);
7272
};
7373

74-
function AsyncParallelBailHook(args = []) {
75-
const hook = new Hook(args);
74+
function AsyncParallelBailHook(args = [], name = undefined) {
75+
const hook = new Hook(args, name);
7676
hook.constructor = AsyncParallelBailHook;
7777
hook.compile = COMPILE;
7878
hook._call = undefined;

lib/AsyncParallelHook.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ const COMPILE = function(options) {
2323
return factory.create(options);
2424
};
2525

26-
function AsyncParallelHook(args = []) {
27-
const hook = new Hook(args);
26+
function AsyncParallelHook(args = [], name = undefined) {
27+
const hook = new Hook(args, name);
2828
hook.constructor = AsyncParallelHook;
2929
hook.compile = COMPILE;
3030
hook._call = undefined;

lib/AsyncSeriesBailHook.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ const COMPILE = function(options) {
2828
return factory.create(options);
2929
};
3030

31-
function AsyncSeriesBailHook(args = []) {
32-
const hook = new Hook(args);
31+
function AsyncSeriesBailHook(args = [], name = undefined) {
32+
const hook = new Hook(args, name);
3333
hook.constructor = AsyncSeriesBailHook;
3434
hook.compile = COMPILE;
3535
hook._call = undefined;

lib/AsyncSeriesHook.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ const COMPILE = function(options) {
2323
return factory.create(options);
2424
};
2525

26-
function AsyncSeriesHook(args = []) {
27-
const hook = new Hook(args);
26+
function AsyncSeriesHook(args = [], name = undefined) {
27+
const hook = new Hook(args, name);
2828
hook.constructor = AsyncSeriesHook;
2929
hook.compile = COMPILE;
3030
hook._call = undefined;

lib/AsyncSeriesLoopHook.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ const COMPILE = function(options) {
2323
return factory.create(options);
2424
};
2525

26-
function AsyncSeriesLoopHook(args = []) {
27-
const hook = new Hook(args);
26+
function AsyncSeriesLoopHook(args = [], name = undefined) {
27+
const hook = new Hook(args, name);
2828
hook.constructor = AsyncSeriesLoopHook;
2929
hook.compile = COMPILE;
3030
hook._call = undefined;

lib/AsyncSeriesWaterfallHook.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ const COMPILE = function(options) {
3131
return factory.create(options);
3232
};
3333

34-
function AsyncSeriesWaterfallHook(args = []) {
34+
function AsyncSeriesWaterfallHook(args = [], name = undefined) {
3535
if (args.length < 1)
3636
throw new Error("Waterfall hooks must have at least one argument");
37-
const hook = new Hook(args);
37+
const hook = new Hook(args, name);
3838
hook.constructor = AsyncSeriesWaterfallHook;
3939
hook.compile = COMPILE;
4040
hook._call = undefined;

lib/HookMap.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ const util = require("util");
99
const defaultFactory = (key, hook) => hook;
1010

1111
class HookMap {
12-
constructor(factory) {
12+
constructor(factory, name = undefined) {
1313
this._map = new Map();
14+
this.name = name;
1415
this._factory = factory;
1516
this._interceptors = [];
1617
}

lib/MultiHook.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
const Hook = require("./Hook");
88

99
class MultiHook {
10-
constructor(hooks) {
10+
constructor(hooks, name = undefined) {
1111
this.hooks = hooks;
12+
this.name = name;
1213
}
1314

1415
tap(options, fn) {
@@ -43,7 +44,10 @@ class MultiHook {
4344
}
4445

4546
withOptions(options) {
46-
return new MultiHook(this.hooks.map(h => h.withOptions(options)));
47+
return new MultiHook(
48+
this.hooks.map(h => h.withOptions(options)),
49+
this.name
50+
);
4751
}
4852
}
4953

lib/SyncBailHook.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ const COMPILE = function(options) {
3737
return factory.create(options);
3838
};
3939

40-
function SyncBailHook(args = []) {
41-
const hook = new Hook(args);
40+
function SyncBailHook(args = [], name = undefined) {
41+
const hook = new Hook(args, name);
4242
hook.constructor = SyncBailHook;
4343
hook.tapAsync = TAP_ASYNC;
4444
hook.tapPromise = TAP_PROMISE;

lib/SyncHook.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ const COMPILE = function(options) {
3232
return factory.create(options);
3333
};
3434

35-
function SyncHook(args = []) {
36-
const hook = new Hook(args);
35+
function SyncHook(args = [], name = undefined) {
36+
const hook = new Hook(args, name);
3737
hook.constructor = SyncHook;
3838
hook.tapAsync = TAP_ASYNC;
3939
hook.tapPromise = TAP_PROMISE;

lib/SyncLoopHook.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ const COMPILE = function(options) {
3232
return factory.create(options);
3333
};
3434

35-
function SyncLoopHook(args = []) {
36-
const hook = new Hook(args);
35+
function SyncLoopHook(args = [], name = undefined) {
36+
const hook = new Hook(args, name);
3737
hook.constructor = SyncLoopHook;
3838
hook.tapAsync = TAP_ASYNC;
3939
hook.tapPromise = TAP_PROMISE;

lib/SyncWaterfallHook.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ const COMPILE = function(options) {
4141
return factory.create(options);
4242
};
4343

44-
function SyncWaterfallHook(args = []) {
44+
function SyncWaterfallHook(args = [], name = undefined) {
4545
if (args.length < 1)
4646
throw new Error("Waterfall hooks must have at least one argument");
47-
const hook = new Hook(args);
47+
const hook = new Hook(args, name);
4848
hook.constructor = SyncWaterfallHook;
4949
hook.tapAsync = TAP_ASYNC;
5050
hook.tapPromise = TAP_PROMISE;

tapable.d.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,16 @@ interface HookMapInterceptor<H> {
8585
}
8686

8787
export class HookMap<H> {
88-
constructor(factory: HookFactory<H>);
88+
constructor(factory: HookFactory<H>, name?: string);
89+
name: string | undefined;
8990
get(key: any): H | undefined;
9091
for(key: any): H;
9192
intercept(interceptor: HookMapInterceptor<H>): void;
9293
}
9394

9495
export class MultiHook<H> {
95-
constructor(hooks: H[]);
96+
constructor(hooks: H[], name?: string);
97+
name: string | undefined;
9698
tap(options: string | Tap, fn?: Function): void;
9799
tapAsync(options: string | Tap, fn?: Function): void;
98100
tapPromise(options: string | Tap, fn?: Function): void;

0 commit comments

Comments
 (0)