Projekt

Obecné

Profil

Stáhnout (858 Bajtů) Statistiky
| Větev: | Revize:
1
/*
2
	MIT License http://www.opensource.org/licenses/mit-license.php
3
	Author Tobias Koppers @sokra
4
*/
5
"use strict";
6

    
7
const basename = require("./getPaths").basename;
8

    
9
module.exports = class CloneBasenamePlugin {
10
	constructor(source, target) {
11
		this.source = source;
12
		this.target = target;
13
	}
14

    
15
	apply(resolver) {
16
		const target = resolver.ensureHook(this.target);
17
		resolver.getHook(this.source).tapAsync("CloneBasenamePlugin", (request, resolveContext, callback) => {
18
			const filename = basename(request.path);
19
			const filePath = resolver.join(request.path, filename);
20
			const obj = Object.assign({}, request, {
21
				path: filePath,
22
				relativePath: request.relativePath && resolver.join(request.relativePath, filename)
23
			});
24
			resolver.doResolve(target, obj, "using path: " + filePath, resolveContext, callback);
25
		});
26
	}
27
};
(5-5/39)