We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fc4f4ac commit 450f85aCopy full SHA for 450f85a
lib/cli.js
@@ -98,7 +98,7 @@ cli.run = function() {
98
initLogLevel();
99
initDir()
100
initPlugins(function(e) {
101
- if (e) return log.error(e);
+ if (e) return log.fatal(e);
102
cache.init();
103
runCommand();
104
});
lib/commands/config.js
@@ -75,14 +75,14 @@ cmd.handler = function(argv) {
75
76
// delete
77
if (argv.delete) {
78
- if (v === undefined) return log.error('Key not found: ' + argv.key);
+ if (v === undefined) return log.fatal('Key not found: ' + argv.key);
79
nconf.clear(argv.key);
80
return saveConfig();
81
}
82
83
// show
84
if (argv.value.length === 0) {
85
86
return log.info(prettyConfig(v));
87
88
lib/commands/plugin.js
@@ -80,7 +80,7 @@ cmd.handler = function(argv) {
if (argv.install) {
const cb = function(e, p) {
p.help();
p.save();
Plugin.init();
@@ -96,11 +96,11 @@ cmd.handler = function(argv) {
96
97
if (name) plugins = plugins.filter(x => x.name === name);
- if (plugins.length === 0) return log.error('Plugin not found!');
+ if (plugins.length === 0) return log.fatal('Plugin not found!');
const p = plugins[0];
if (p.missing && (argv.enable || argv.disable))
- return log.error('Plugin missing, install it first');
+ return log.fatal('Plugin missing, install it first');
105
if (argv.enable) {
106
p.enabled = true;
lib/commands/submit.js
@@ -44,7 +44,7 @@ function printLine() {
44
cmd.handler = function(argv) {
45
session.argv = argv;
46
if (!file.exist(argv.filename))
47
- return log.error('File ' + argv.filename + ' not exist!');
+ return log.fatal('File ' + argv.filename + ' not exist!');
48
49
const meta = file.meta(argv.filename);
50
lib/commands/test.js
@@ -54,7 +54,7 @@ function printResult(actual, expect, k) {
54
55
function runTest(argv) {
56
57
58
59
60
lib/log.js
@@ -25,7 +25,16 @@ log.isEnabled = function(name) {
25
};
26
27
log.fail = function(e) {
28
- log.error(sprintf('%s [%d]', (e.msg || e), (e.statusCode || 0)));
+ let msg = sprintf('%s', (e.msg || e));
29
+ if (e.statusCode) {
30
+ msg += sprintf(' [code=%d]', e.statusCode);
31
+ }
32
+ log.error(msg);
33
+};
34
+
35
+log.fatal = function(e) {
36
+ log.error(e);
37
+ process.exit(1);
38
39
40
log.printf = function() {
test/test_log.js
@@ -93,10 +93,10 @@ describe('log', function() {
93
94
it('should ok with log.fail', function() {
95
log.fail({msg: 'some error', statusCode: 500});
- assert.equal(expected, chalk.red('[ERROR] some error [500]'));
+ assert.equal(expected, chalk.red('[ERROR] some error [code=500]'));
log.fail('some error');
- assert.equal(expected, chalk.red('[ERROR] some error [0]'));
+ assert.equal(expected, chalk.red('[ERROR] some error'));
}); // #levels
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments