npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/DepBlockHelpers.js

Statements: 21.05% (4 / 19)      Branches: 0% (0 / 18)      Functions: 0% (0 / 5)      Lines: 22.22% (4 / 18)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/dependencies/ » DepBlockHelpers.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44        1   1                 1                                             1          
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
var DepBlockHelpers = exports;
 
DepBlockHelpers.getLoadDepBlockWrapper = function(depBlock, outputOptions, requestShortener, name) {
	var promiseCode = DepBlockHelpers.getDepBlockPromise(depBlock, outputOptions, requestShortener, name);
	return [
		promiseCode + ".then(",
		").catch(",
		")"
	];
};
 
DepBlockHelpers.getDepBlockPromise = function(depBlock, outputOptions, requestShortener, name) {
	if(depBlock.chunks) {
		var chunks = depBlock.chunks.filter(function(chunk) {
			return !chunk.hasRuntime() && chunk.id !== null;
		});
		if(chunks.length === 1) {
			var chunk = chunks[0];
			return "__webpack_require__.e" + asComment(name) + "(" + JSON.stringify(chunk.id) + "" +
				(outputOptions.pathinfo && depBlock.chunkName ? "/*! " + requestShortener.shorten(depBlock.chunkName) + " */" : "") +
				asComment(depBlock.chunkReason) + ")";
		} else if(chunks.length > 0) {
			return "Promise.all" + asComment(name) + "(" +
				(outputOptions.pathinfo && depBlock.chunkName ? "/*! " + requestShortener.shorten(depBlock.chunkName) + " */" : "") +
				"[" +
				chunks.map(function(chunk) {
					return "__webpack_require__.e(" + JSON.stringify(chunk.id) + ")";
				}).join(", ") +
				"])";
		}
	}
	return "Promise.resolve()";
};
 
function asComment(str) {
	if(!str) return "";
	return "/* " + str + " */";
}