|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
982 bytes
|
| Rev | Line | |
|---|
| [9af201e] | 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 | }
|
|---|
| 31 | resolver.hooks.result.callAsync(obj, resolverContext, (err) => {
|
|---|
| 32 | if (err) return callback(err);
|
|---|
| 33 | if (typeof resolverContext.yield === "function") {
|
|---|
| 34 | resolverContext.yield(obj);
|
|---|
| 35 | callback(null, null);
|
|---|
| 36 | } else {
|
|---|
| 37 | callback(null, obj);
|
|---|
| 38 | }
|
|---|
| 39 | });
|
|---|
| 40 | },
|
|---|
| 41 | );
|
|---|
| 42 | }
|
|---|
| 43 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.