Skip to content

Commit

Permalink
refactor: use nanocolors instead of chalk (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW authored Oct 2, 2021
1 parent e6fcc64 commit 96edf3e
Show file tree
Hide file tree
Showing 6 changed files with 6,324 additions and 14 deletions.
6 changes: 3 additions & 3 deletions lib/console/help.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const chalk = require('chalk');
const { underline, bold } = require('nanocolors');
const { readFile } = require('hexo-fs');
const { join } = require('path');
const Promise = require('bluebird');
Expand Down Expand Up @@ -70,7 +70,7 @@ function printAllHelp(list) {
]);

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

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

console.log(str);
Expand Down
4 changes: 2 additions & 2 deletions lib/console/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

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

Expand Down
4 changes: 2 additions & 2 deletions lib/context.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const logger = require('hexo-log');
const chalk = require('chalk');
const { underline } = require('nanocolors');
const { EventEmitter } = require('events');
const Promise = require('bluebird');
const ConsoleExtend = require('./extend/console');
Expand Down Expand Up @@ -46,7 +46,7 @@ class Context extends EventEmitter {
this.log.fatal(
{err},
'Something\'s wrong. Maybe you can find the solution here: %s',
chalk.underline('http://hexo.io/docs/troubleshooting.html')
underline('http://hexo.io/docs/troubleshooting.html')
);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/hexo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const chalk = require('chalk');
const { magenta } = require('nanocolors');
const tildify = require('tildify');
const Promise = require('bluebird');
const Context = require('./context');
Expand Down Expand Up @@ -36,7 +36,7 @@ function entry(cwd = process.cwd(), args) {

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

0 comments on commit 96edf3e

Please sign in to comment.