main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
971 bytes
|
Rev | Line | |
---|
[79a0317] | 1 | /*
|
---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
| 3 | Author Tobias Koppers @sokra
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | "use strict";
|
---|
| 7 |
|
---|
| 8 | /** @typedef {import("./Resolver")} Resolver */
|
---|
| 9 | /** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */
|
---|
| 10 |
|
---|
| 11 | module.exports = class ResultPlugin {
|
---|
| 12 | /**
|
---|
| 13 | * @param {ResolveStepHook} source source
|
---|
| 14 | */
|
---|
| 15 | constructor(source) {
|
---|
| 16 | this.source = source;
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | /**
|
---|
| 20 | * @param {Resolver} resolver the resolver
|
---|
| 21 | * @returns {void}
|
---|
| 22 | */
|
---|
| 23 | apply(resolver) {
|
---|
| 24 | this.source.tapAsync(
|
---|
| 25 | "ResultPlugin",
|
---|
| 26 | (request, resolverContext, callback) => {
|
---|
| 27 | const obj = { ...request };
|
---|
| 28 | if (resolverContext.log)
|
---|
| 29 | resolverContext.log("reporting result " + obj.path);
|
---|
| 30 | resolver.hooks.result.callAsync(obj, resolverContext, err => {
|
---|
| 31 | if (err) return callback(err);
|
---|
| 32 | if (typeof resolverContext.yield === "function") {
|
---|
| 33 | resolverContext.yield(obj);
|
---|
| 34 | callback(null, null);
|
---|
| 35 | } else {
|
---|
| 36 | callback(null, obj);
|
---|
| 37 | }
|
---|
| 38 | });
|
---|
| 39 | }
|
---|
| 40 | );
|
---|
| 41 | }
|
---|
| 42 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.