一份比较常用的在这里

wait-on

Wait-on作阻塞式等待

  1. wait-on file1 && NEXT_CMD # wait for file1, then exec NEXT_CMD
  2. wait-on f1 f2 && NEXT_CMD # wait for both f1 and f2, the exec NEXT_CMD
  3. wait-on http://localhost:8000/foo && NEXT_CMD # wait for http 2XX HEAD
  4. wait-on https://myserver/foo && NEXT_CMD # wait for https 2XX HEAD
  5. wait-on http-get://localhost:8000/foo && NEXT_CMD # wait for http 2XX GET
  6. wait-on https-get://myserver/foo && NEXT_CMD # wait for https 2XX GET
  7. wait-on tcp:4000 && NEXT_CMD # wait for service to listen on a TCP port
  8. wait-on socket:/path/mysock # wait for service to listen on domain socket
  9. wait-on http://unix:/var/SOCKPATH:/a/foo # wait for http HEAD on domain socket
  10. wait-on http-get://unix:/var/SOCKPATH:/a/foo # wait for http GET on domain socket

concurrently

并行执行命令的库

  1. "start": "concurrently \"command1 arg\" \"command2 arg\""

log4js

更好的控制台输出,支持记录日志文件。文档在这里,比较详细的介绍在这里

  1. var log4js = require("log4js");
  2. var logger = log4js.getLogger();
  3. logger.level = "debug";
  4. logger.debug("Some debug messages");

一个简单的配置文件如下log4js.config.json
log4js.png
appenders:必须有,键值对形式,定义了使用的输出类型
categories:必须有,至少有default键,指定对应appenders输出的等级ALL < TRACE < DEBUG < INFO < WARN < ERROR < FATAL < MARK < OFF


nodemon

nodejs监控文件并且热替换
安装
npm install -g nodemon
使用
nodemon [your node app]


Commander

Node命令行必知必会工具,用来解析命令行。作者TJ Holowaychuk,不知道他你可以不用学前端了。

安装:

npm install commander

链式方法

command:自定义执行的命令
option:可选参数
alias:用于 执行命令的别名
description:命令描述
action:执行命令后所执行的方法
usage:用户使用提示
parse:解析命令行参数,注意这个方法一定要放到最后调用

作者:忍不住的k
链接:https://www.jianshu.com/p/9ff49cb88204
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

fs-extra

node原生模块的替代品,包含了mkdirprimrafncp并且自带了promisify

安装

npm install fs-extra

  1. //async await
  2. async function copyFiles () {
  3. try {
  4. await fs.copy('/tmp/myfile', '/tmp/mynewfile')
  5. console.log('success!')
  6. } catch (err) {
  7. console.error(err)
  8. }
  9. }

figlet

酷炫的登陆欢迎语,极客就该有极客的范儿

  1. var figlet = require('figlet');
  2. figlet('Hello World!!', function(err, data) {
  3. if (err) {
  4. console.log('Something went wrong...');
  5. console.dir(err);
  6. return;
  7. }
  8. console.log(data)
  9. });
  10. //_ _ _ _ __ __ _ _ _ _
  11. | | | | ___| | | ___ \ \ / /__ _ __| | __| | | |
  12. | |_| |/ _ \ | |/ _ \ \ \ /\ / / _ \| '__| |/ _` | | |
  13. | _ | __/ | | (_) | \ V V / (_) | | | | (_| |_|_|
  14. |_| |_|\___|_|_|\___/ \_/\_/ \___/|_| |_|\__,_(_|_)