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:
1.2 KB
|
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").ResolveRequest} ResolveRequest */
|
---|
| 10 | /** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */
|
---|
| 11 |
|
---|
| 12 | module.exports = class JoinRequestPlugin {
|
---|
| 13 | /**
|
---|
| 14 | * @param {string | ResolveStepHook} source source
|
---|
| 15 | * @param {string | ResolveStepHook} target target
|
---|
| 16 | */
|
---|
| 17 | constructor(source, target) {
|
---|
| 18 | this.source = source;
|
---|
| 19 | this.target = target;
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | /**
|
---|
| 23 | * @param {Resolver} resolver the resolver
|
---|
| 24 | * @returns {void}
|
---|
| 25 | */
|
---|
| 26 | apply(resolver) {
|
---|
| 27 | const target = resolver.ensureHook(this.target);
|
---|
| 28 | resolver
|
---|
| 29 | .getHook(this.source)
|
---|
| 30 | .tapAsync("JoinRequestPlugin", (request, resolveContext, callback) => {
|
---|
| 31 | const requestPath = /** @type {string} */ (request.path);
|
---|
| 32 | const requestRequest = /** @type {string} */ (request.request);
|
---|
| 33 | /** @type {ResolveRequest} */
|
---|
| 34 | const obj = {
|
---|
| 35 | ...request,
|
---|
| 36 | path: resolver.join(requestPath, requestRequest),
|
---|
| 37 | relativePath:
|
---|
| 38 | request.relativePath &&
|
---|
| 39 | resolver.join(request.relativePath, requestRequest),
|
---|
| 40 | request: undefined
|
---|
| 41 | };
|
---|
| 42 | resolver.doResolve(target, obj, null, resolveContext, callback);
|
---|
| 43 | });
|
---|
| 44 | }
|
---|
| 45 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.