madrun

2019-06-24 admin

madrun是什么

什么是madrun,CLI tool to run multiple npm-scripts in a madly comfortable way

madrun使用教程帮助文档

Madrun License NPM version Dependency Status Build Status Coverage Status

CLI tool to run multiple npm-scripts in a madly comfortable way. Can be used together with redrun.

Install

npm i madrun -g

Usage

First thing you should do is create madrun.js file. This can be done using:

madrun --init

madrun will import all scripts to madrun.js, and add it to .npmignore.

When update madrun.js, adding new scripts, run madrun --init again, to update package.json, so you can use:

npm run new-script-name

Then you can run madrun without args to see list of a scripts. Or run:

madrun <script>

To run specified script.

Completion

You can enable tab-completion of npm scripts similar to npm’s completion using:

madrun-completion >> ~/.bashrc
madrun-completion >> ~/.zshrc

You may also pipe the output of madrun-completion to a file such as /usr/local/etc/bash_completion.d/madrun if you have a system that will read that file for you.

API

madrun supports next API set:

run(name, [opt])

Run script by a name or regexp.

  • name - name of a sript
  • opt - options to run with
  • scripts - all scripts set (need for embedding only)

series(names, [opt, scripts])

Run scripts by a name or regexp one-by-one.

  • name - array of names of scrips
  • opt - options to run with
  • scripts - all scripts set (need for embedding only)

parallel (names, [opt, scripts])

Run scripts by a name or regexp parallel.

  • name - array of names of scrips
  • opt - options to run with
  • scripts - all scripts set (need for embedding only)

Example

Let’s install madrun and save it as devDependency with:

npm i madrun -D

Let’s create file madrun.js:

const {
    run,
    parallel,
} = require('madrun');

module.exports = {
    'lint:lib': 'eslint lib',
    'lint:bin': 'eslint bin',
    'lint': run('lint:*'),
    'fix:lint': parallel(['lint:lib', 'lint:bin'], 'fix'),
};

Now you can call any of listed scripts with help of madrun cli:

$ madrun lint
> eslint lib && eslint bin

For parallel fix with can use:

$ madrun fix:lint
> eslint eslint lib --fix & eslin bin --fix

Related

  • redrun - CLI tool to run multiple npm-scripts fast.

License

MIT

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-68082.html

文章标题:madrun

回到顶部