文章

commander.js

GitHub - tj/commander.js: node.js command-line interfaces made easy

玩转 Commander.js —— 你也是命令行大师-腾讯云开发者社区-腾讯云

一些有用的工具

  • left-pad - 常用来制表,对齐(广为流传的一个包..)
1
2
3
4
5
6
7
8
9
const leftPad = require('left-pad')

leftPad('foo', 5) // => "  foo"

leftPad('foobar', 6) // => "foobar"

leftPad(1, 2, '0') // => "01"

leftPad(17, 5, 0) // => "00017"
  • chalk - 控制命令行文本样式
1
2
3
4
const chalk = require('chalk');

console.log(chalk.blue('Hello world!'));

  • ora - 终端加载动效
1
2
3
4
5
6
7
8
9
const ora = require('ora');

const spinner = ora('Loading unicorns').start();

setTimeout(() => {
    spinner.color = 'yellow';
    spinner.text = 'Loading rainbows';
}, 1000);

  • Pkg 打包 nodesjs 成可执行程序
本文由作者按照 CC BY 4.0 进行授权