Sha256: e5968cdd55e53dc522f542cdddd6d07f348c3b89a09e754405c934b065623e37

Contents?: true

Size: 1.67 KB

Versions: 13

Compression:

Stored size: 1.67 KB

Contents

/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";

const DescriptionFileUtils = require("./DescriptionFileUtils");

module.exports = class DescriptionFilePlugin {
	constructor(source, filenames, target) {
		this.source = source;
		this.filenames = [].concat(filenames);
		this.target = target;
	}

	apply(resolver) {
		const target = resolver.ensureHook(this.target);
		resolver.getHook(this.source).tapAsync("DescriptionFilePlugin", (request, resolveContext, callback) => {
			const directory = request.path;
			DescriptionFileUtils.loadDescriptionFile(resolver, directory, this.filenames, resolveContext, (err, result) => {
				if(err) return callback(err);
				if(!result) {
					if(resolveContext.missing) {
						this.filenames.forEach((filename) => {
							resolveContext.missing.add(resolver.join(directory, filename));
						});
					}
					if(resolveContext.log) resolveContext.log("No description file found");
					return callback();
				}
				const relativePath = "." + request.path.substr(result.directory.length).replace(/\\/g, "/");
				const obj = Object.assign({}, request, {
					descriptionFilePath: result.path,
					descriptionFileData: result.content,
					descriptionFileRoot: result.directory,
					relativePath: relativePath
				});
				resolver.doResolve(target, obj, "using description file: " + result.path + " (relative path: " + relativePath + ")", resolveContext, (err, result) => {
					if(err) return callback(err);

					// Don't allow other processing
					if(result === undefined) return callback(null, null);
					callback(null, result);
				});
			});
		});
	}
};

Version data entries

13 entries across 13 versions & 6 rubygems

Version Path
disco_app-0.18.0 test/dummy/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js
disco_app-0.18.2 test/dummy/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js
enju_library-0.3.8 spec/dummy/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js
jester-data-8.0.0 node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js
ezii-os-5.2.1 node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js
ezii-os-2.0.1 node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js
ezii-os-1.1.0 node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js
ezii-os-1.0.0 node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js
ezii-os-0.0.0.1.0 node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js
ezii-os-0.0.0.0.1 node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js
locomotivecms-4.0.0.alpha1 app/javascript/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js
locomotivecms-3.4.0 app/javascript/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js
dragonfly_puppeteer-0.1.0 node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js