Skip to content

Commit 9e7f4ce

Browse files
committed
🎨 重整结构, 向下兼容.
1 parent a8e931d commit 9e7f4ce

File tree

17 files changed

+19
-17
lines changed

17 files changed

+19
-17
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @zyao89

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'virtualFile',
1111
].forEach(m => {
1212
Object.assign(exports, {
13-
[m]: require(`./libs/${m}`),
13+
[m]: require(`./src/${m}`),
1414
});
1515
});
1616

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
"url": "https://github.com/MicrosApp/MicroApp-Shared-Utils/issues"
1818
},
1919
"files": [
20-
"constants",
21-
"libs",
20+
"src",
2221
"index.js"
2322
],
2423
"keywords": [
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const toString = require('stream-to-string');
44
const cheerio = require('cheerio');
55
const stream = require('stream');
66

7-
const CONSTANTS = require('../constants');
7+
const CONSTANTS = require('./constants');
88

99
module.exports = async function injectHtml(ctx) {
1010
// 处理文件注入一些信息
File renamed without changes.

libs/logger.js renamed to src/logger.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
'use strict';
22

3-
const chalk = require('chalk').default;
3+
const chalk = require('chalk');
44
const utils = require('util');
55
const ora = require('ora');
6+
const os = require('os');
67

78
const getStdoutMethod = function(type) {
89
if (!process) {
@@ -20,30 +21,30 @@ const getStdoutMethod = function(type) {
2021
const toString = {
2122
debug() {
2223
const message = utils.format(...(arguments || []));
23-
return `${chalk.bgMagenta(' DEBUG ')} ${message} \r\n`;
24+
return `${chalk.bgMagenta(' DEBUG ')} ${message} ${os.EOL}`;
2425
},
2526
warn() {
2627
const message = utils.format(...(arguments || []));
27-
return `${chalk.bgYellowBright.black(' WARN ')} ${chalk.yellowBright(message)} \r\n`;
28+
return `${chalk.bgYellowBright.black(' WARN ')} ${chalk.yellowBright(message)} ${os.EOL}`;
2829
},
2930
error() {
3031
const message = utils.format(...(arguments || []));
31-
return `${chalk.bgRed(' ERROR ')} ${chalk.redBright(message)} \r\n`;
32+
return `${chalk.bgRed(' ERROR ')} ${chalk.redBright(message)} ${os.EOL}`;
3233
},
3334
info() {
3435
const message = utils.format(...(arguments || []));
35-
return `${chalk.bgBlue(' INFO ')} ${chalk.blueBright(message)} \r\n`;
36+
return `${chalk.bgBlue(' INFO ')} ${chalk.blueBright(message)} ${os.EOL}`;
3637
},
3738
success() {
3839
const message = utils.format(...(arguments || []));
39-
return `${chalk.bgHex('#007007')(' SUCCESS ')} ${chalk.greenBright(message)} \r\n`;
40+
return `${chalk.bgHex('#007007')(' SUCCESS ')} ${chalk.greenBright(message)} ${os.EOL}`;
4041
},
4142
};
4243

4344
module.exports = {
4445
toString,
4546
debug() {
46-
if (!process.env.MICRO_DEBUG_LOGGER) return; // 是否开启
47+
if (!process.env.MICRO_APP_DEBUG_LOGGER) return; // 是否开启
4748
return getStdoutMethod('log')(toString.debug.call(toString, ...arguments));
4849
},
4950
warn() {
@@ -79,12 +80,12 @@ module.exports = {
7980
const error = e;
8081
this.error(...Array.prototype.splice.call(arguments, 1));
8182
const stack = error.stack.split(/\r?\n/mg);
82-
getStdoutMethod('error')(chalk.grey(stack.slice(1).join('\r\n')) + '\r\n');
83+
getStdoutMethod('error')(chalk.grey(stack.slice(1).join(os.EOL)) + os.EOL);
8384
} else {
8485
const error = new Error();
8586
this.error(...arguments);
8687
const stack = error.stack.split(/\r?\n/mg);
87-
getStdoutMethod('error')(chalk.grey(stack.slice(2).join('\r\n')) + '\r\n');
88+
getStdoutMethod('error')(chalk.grey(stack.slice(2).join(os.EOL)) + os.EOL);
8889
}
8990
process.exit(1);
9091
},

0 commit comments

Comments
 (0)