npm multi script execute concurrently All In One
npm multi script execute concurrently All In One
{
//...
"scripts": {
// (npm run dev:build & npm run dev:auto) 可以使用通配符 * 简写为 npm:dev:*
"dev": "concurrently npm:dev:*",
"dev": "concurrently npm run dev:build & npm run dev:auto",
"dev": "concurrently \"npm run dev:build\" \"npm run dev:auto\"",
"dev:build": "tsc -w",
"dev:auto": "nodemon node ./dist/app.js",
},
// ...
}
# terminal 1
$ npm run dev
# 等价于 ✅
$ concurrently "npm run dev:build" "npm run dev:auto"
# 等价于 ❌
$ npm run dev:build && npm run dev:auto
等价于 terminal 1 + terminal 2
# terminal 1
$ npm run dev:build
# terminal 2
$ npm run dev:auto
demo
{
"name": "crawler",
"version": "1.0.0",
"description": "",
"main": "./src/crawler.ts",
"scripts": {
"dev-all": "concurrently \"npm run dev:build-all\" \"npm run dev:auto\"",
"dev:build-all": "tsc -w",
"dev:build": "tsc -w ./src/crawler.ts",
"dev:auto": "nodemon node ./dist/app.js",
"dev:auto-local": "./node_modules/nodemon/bin/nodemon.js ./dist/app.js",
"dev": "ts-node ./src/app.ts",
"build": "tsc -w ./src/crawler.ts",
"build-all": "tsc -w",
"auto": "./node_modules/nodemon/bin/nodemon.js ./dist/app.js",
"auto-test": "nodemon node ./dist/app.js",
"app": "tsc ./src/app.ts",
"url": "node ./src/url.js",
"mk": "node ./src/mkdir.js",
"mk-src": "node ./src/mkdir-src.js",
"cjs": "node ./src/mkdir.cjs",
"pdf": "node ./src/pdf.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"type-esm": "module",
"type-flag": "module",
"author": "xgqfrms",
"license": "MIT",
"devDependencies": {
"@types/superagent": "^4.1.15",
"cheerio": "^1.0.0-rc.10",
"concurrently": "^7.1.0",
"nodemon": "^2.0.15",
"pdf-crawler": "^1.0.0",
"request": "^2.88.2",
"request-promise-native": "^1.0.9",
"superagent": "^7.1.2",
"ts-node": "^10.7.0"
}
}
concurrently
https://www.npmjs.com/package/concurrently
npm-run-all
https://www.npmjs.com/package/npm-run-all
Linux terminal bash shell 中 &&
与 &
区别
并行
串行
shell 中 && 和 & 的区别
&
是使用并行模式执行多个命令,同时并行执行左右边命令;
$ npm run dev:build & npm run dev:auto
{
//...
"scripts": {
"dev": "npm run dev:build & npm run dev:auto",
"dev:build": "tsc -w",
"dev:auto": "nodemon node ./dist/app.js",
},
// ...
}
&&
是使用串行模式执行多个命令,先执行左边命令,再执行右边命令 (先左后右,依次执行);
$ npm run dev:build && npm run dev:auto
{
//...
"scripts": {
"dev": "npm run dev:build && npm run dev:auto",
"dev:build": "tsc -w",
"dev:auto": "nodemon node ./dist/app.js",
},
// ...
}
https://yisenfe.github.io/zaji-01/
refs
https://www.npmjs.com/package/pdf-crawler
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/16137768.html
未经授权禁止转载,违者必究!