Skip to content

Commit 8e8326f

Browse files
committed
:feat: 修改npmlog引用,全局唯一
1 parent a9072d7 commit 8e8326f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/logger/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ const format = {
133133

134134
class Logger {
135135

136-
constructor(log, { alias = new Map() }) {
137-
this.npmlog = log;
138-
this.aliasMap = new Map(alias);
136+
constructor() {
137+
this.npmlog = npmlog;
138+
this.aliasMap = new Map();
139139
}
140140

141141
checkLevel(l) {
@@ -270,8 +270,8 @@ class Logger {
270270
}
271271
}
272272

273-
function factroy(log, opts = {}) {
274-
return new Proxy(new Logger(log, opts), {
273+
function factroy() {
274+
return new Proxy(new Logger(), {
275275
get(target, prop) {
276276
if (prop in target) {
277277
return target[prop];
@@ -283,21 +283,21 @@ function factroy(log, opts = {}) {
283283
if (alias) {
284284
return target.getMethod(alias);
285285
}
286-
const item = log[prop];
286+
const item = npmlog[prop];
287287
if (_.isFunction(item)) {
288-
return item.bind(log);
288+
return item.bind(npmlog);
289289
}
290290
return item;
291291
},
292292
set(target, prop, value) {
293-
log[prop] = value;
293+
target[prop] = value;
294294
return true;
295295
},
296296
});
297297
}
298298

299299
function createInstance() {
300-
return factroy(npmlog);
300+
return factroy();
301301
}
302302

303303
module.exports = createInstance();

0 commit comments

Comments
 (0)