Projekt

Obecné

Profil

Stáhnout (1.17 KB) Statistiky
| Větev: | Revize:
1 3a515b92 cagy
/*
2
	MIT License http://www.opensource.org/licenses/mit-license.php
3
	Author Tobias Koppers @sokra
4
*/
5
"use strict";
6
7
const util = require("util");
8
9
// TODO remove in enhanced-resolve 5
10
module.exports = util.deprecate(function createInnerCallback(callback, options, message, messageOptional) {
11
	const log = options.log;
12
	if(!log) {
13
		if(options.stack !== callback.stack) {
14
			const callbackWrapper = function callbackWrapper() {
15
				return callback.apply(this, arguments);
16
			};
17
			callbackWrapper.stack = options.stack;
18
			callbackWrapper.missing = options.missing;
19
			return callbackWrapper;
20
		}
21
		return callback;
22
	}
23
24
	function loggingCallbackWrapper() {
25
		return callback.apply(this, arguments);
26
27
	}
28
	if(message) {
29
		if(!messageOptional) {
30
			log(message);
31
		}
32
		loggingCallbackWrapper.log = function writeLog(msg) {
33
			if(messageOptional) {
34
				log(message);
35
				messageOptional = false;
36
			}
37
			log("  " + msg);
38
		};
39
	} else {
40
		loggingCallbackWrapper.log = function writeLog(msg) {
41
			log(msg);
42
		};
43
	}
44
	loggingCallbackWrapper.stack = options.stack;
45
	loggingCallbackWrapper.missing = options.missing;
46
	return loggingCallbackWrapper;
47
}, "Pass resolveContext instead and use createInnerContext");