Skip to content

refactor: use nanocolors instead of chalk #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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