Sha256: e270dae00b864cecdb5f64b6a04092177c832eae782d94d90191b0f3a19967bf

Contents?: true

Size: 1.02 KB

Versions: 62

Compression:

Stored size: 1.02 KB

Contents

/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
function FileAppendPlugin(appendings) {
	this.appendings = appendings;
}
module.exports = FileAppendPlugin;

FileAppendPlugin.prototype.apply = function(resolver) {
	var appendings = this.appendings;
	resolver.plugin("file", function(request, callback) {
		var fs = this.fileSystem;
		var addr = this.join(request.path, request.request);
		var addrs = appendings.map(function(a) { return addr + a });
		var log = callback.log;
		this.forEachBail(addrs, function(addr, callback) {
			fs.stat(addr, function(err, stat) {
				if(!err && stat && stat.isFile())
					return callback(addr);
				if(log) {
					if(err) log(addr + " doesn't exist");
					else log(addr + " is not a file");
				}
				return callback();
			});
		}, function(validAddr) {
			if(!validAddr) return callback();
			return this.doResolve("result", {
				path: validAddr,
				query: request.query,
				file: true,
				resolved: true
			}, callback);
		}.bind(this));
	});
};

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
smock-0.1.268 node_modules/webpack/node_modules/enhanced-resolve/lib/FileAppendPlugin.js
smock-0.1.267 node_modules/webpack/node_modules/enhanced-resolve/lib/FileAppendPlugin.js
smock-0.1.266 node_modules/webpack/node_modules/enhanced-resolve/lib/FileAppendPlugin.js
smock-0.1.265 node_modules/webpack/node_modules/enhanced-resolve/lib/FileAppendPlugin.js
smock-0.1.264 node_modules/webpack/node_modules/enhanced-resolve/lib/FileAppendPlugin.js
smock-0.1.263 node_modules/webpack/node_modules/enhanced-resolve/lib/FileAppendPlugin.js
smock-0.1.262 node_modules/webpack/node_modules/enhanced-resolve/lib/FileAppendPlugin.js
smock-0.1.261 node_modules/webpack/node_modules/enhanced-resolve/lib/FileAppendPlugin.js
smock-0.1.260 node_modules/webpack/node_modules/enhanced-resolve/lib/FileAppendPlugin.js
smock-0.1.259 node_modules/webpack/node_modules/enhanced-resolve/lib/FileAppendPlugin.js
smock-0.1.258 node_modules/webpack/node_modules/enhanced-resolve/lib/FileAppendPlugin.js
smock-0.1.256 node_modules/webpack/node_modules/enhanced-resolve/lib/FileAppendPlugin.js
smock-0.1.255 node_modules/webpack/node_modules/enhanced-resolve/lib/FileAppendPlugin.js
smock-0.1.254 node_modules/webpack/node_modules/enhanced-resolve/lib/FileAppendPlugin.js
smock-0.1.253 node_modules/webpack/node_modules/enhanced-resolve/lib/FileAppendPlugin.js
smock-0.1.252 node_modules/webpack/node_modules/enhanced-resolve/lib/FileAppendPlugin.js
smock-0.1.251 node_modules/webpack/node_modules/enhanced-resolve/lib/FileAppendPlugin.js
smock-0.1.250 node_modules/webpack/node_modules/enhanced-resolve/lib/FileAppendPlugin.js
smock-0.1.249 node_modules/webpack/node_modules/enhanced-resolve/lib/FileAppendPlugin.js
smock-0.1.247 node_modules/webpack/node_modules/enhanced-resolve/lib/FileAppendPlugin.js