Skip to content

Commit 96edf3e

Browse files
authored
refactor: use nanocolors instead of chalk (#334)
1 parent e6fcc64 commit 96edf3e

File tree

6 files changed

+6324
-14
lines changed

6 files changed

+6324
-14
lines changed

lib/console/help.js

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

3-
const chalk = require('chalk');
3+
const { underline, bold } = require('nanocolors');
44
const { readFile } = require('hexo-fs');
55
const { join } = require('path');
66
const Promise = require('bluebird');
@@ -70,7 +70,7 @@ function printAllHelp(list) {
7070
]);
7171

7272
console.log('For more help, you can use \'hexo help [command]\' for the detailed information');
73-
console.log('or you can check the docs:', chalk.underline('http://hexo.io/docs/'));
73+
console.log('or you can check the docs:', underline('http://hexo.io/docs/'));
7474

7575
return Promise.resolve();
7676
}
@@ -95,7 +95,7 @@ function printList(title, list) {
9595
for (let i = 0; i < length; i++) {
9696
const { description = list[i].desc } = list[i];
9797
const pad = ' '.repeat(maxLen - lengths[i] + 2);
98-
str += ` ${chalk.bold(list[i].name)}${pad}${description}\n`;
98+
str += ` ${bold(list[i].name)}${pad}${description}\n`;
9999
}
100100

101101
console.log(str);

lib/console/init.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const Promise = require('bluebird');
44
const { join, resolve } = require('path');
5-
const chalk = require('chalk');
5+
const { magenta } = require('nanocolors');
66
const { existsSync, readdirSync, rmdir, unlink, copyDir, readdir, stat } = require('hexo-fs');
77
const tildify = require('tildify');
88
const { spawn } = require('hexo-util');
@@ -19,7 +19,7 @@ async function initConsole(args) {
1919
const { log } = this;
2020

2121
if (existsSync(target) && readdirSync(target).length !== 0) {
22-
log.fatal(`${chalk.magenta(tildify(target))} not empty, please run \`hexo init\` on an empty folder and then copy your files into it`);
22+
log.fatal(`${magenta(tildify(target))} not empty, please run \`hexo init\` on an empty folder and then copy your files into it`);
2323
await Promise.reject(new Error('target not empty'));
2424
}
2525

lib/context.js

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

33
const logger = require('hexo-log');
4-
const chalk = require('chalk');
4+
const { underline } = require('nanocolors');
55
const { EventEmitter } = require('events');
66
const Promise = require('bluebird');
77
const ConsoleExtend = require('./extend/console');
@@ -46,7 +46,7 @@ class Context extends EventEmitter {
4646
this.log.fatal(
4747
{err},
4848
'Something\'s wrong. Maybe you can find the solution here: %s',
49-
chalk.underline('http://hexo.io/docs/troubleshooting.html')
49+
underline('http://hexo.io/docs/troubleshooting.html')
5050
);
5151
}
5252

lib/hexo.js

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

3-
const chalk = require('chalk');
3+
const { magenta } = require('nanocolors');
44
const tildify = require('tildify');
55
const Promise = require('bluebird');
66
const Context = require('./context');
@@ -36,7 +36,7 @@ function entry(cwd = process.cwd(), args) {
3636

3737
return loadModule(path, args).catch(err => {
3838
log.error(err.message);
39-
log.error('Local hexo loading failed in %s', chalk.magenta(tildify(path)));
39+
log.error('Local hexo loading failed in %s', magenta(tildify(path)));
4040
log.error('Try running: \'rm -rf node_modules && npm install --force\'');
4141
throw new HexoNotFoundError();
4242
});

0 commit comments

Comments
 (0)