createInnerCallback.js
1.18 KB
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
45
46
47
48
49
50
51
52
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const util = require("util");
// TODO remove in enhanced-resolve 5
module.exports = util.deprecate(function createInnerCallback(
callback,
options,
message,
messageOptional
) {
const log = options.log;
if (!log) {
if (options.stack !== callback.stack) {
const callbackWrapper = function callbackWrapper() {
return callback.apply(this, arguments);
};
callbackWrapper.stack = options.stack;
callbackWrapper.missing = options.missing;
return callbackWrapper;
}
return callback;
}
function loggingCallbackWrapper() {
return callback.apply(this, arguments);
}
if (message) {
if (!messageOptional) {
log(message);
}
loggingCallbackWrapper.log = function writeLog(msg) {
if (messageOptional) {
log(message);
messageOptional = false;
}
log(" " + msg);
};
} else {
loggingCallbackWrapper.log = function writeLog(msg) {
log(msg);
};
}
loggingCallbackWrapper.stack = options.stack;
loggingCallbackWrapper.missing = options.missing;
return loggingCallbackWrapper;
},
"Pass resolveContext instead and use createInnerContext");