← 全部工具

npm-failsafe

热度 65 更新于 开发与构建

Executes a sequence of npm scripts.

npmauto-collected

安装

npm
npm install -g npm-failsafe

通过 npm 安装。

NPM Failsafe

[actions-image]: https://github.com/jan-molak/npm-failsafe/workflows/Main/badge.svg [actions-url]: https://github.com/jan-molak/npm-failsafe/actions [npm-stats-image]: https://img.shields.io/npm/dm/npm-failsafe.svg?style=flat [npm-stats-url]: https://npm-stat.com/charts.html?package=npm-failsafe [npm-version-image]: https://badge.fury.io/js/npm-failsafe.svg [npm-version-url]: https://badge.fury.io/js/npm-failsafe

The npm-failsafe lets you execute a sequence of NPM scripts and return the correct exit code should any of them fail.

Installation

npm install --save-dev npm-failsafe

Usage

Failsafe is a command line tool. To view the available options, run the following command in your terminal:

npx failsafe --help

Configuration

You can use failsafe to run scripts defined in your package.json file.

Configuring Failsafe in package.json

If your scripts require any arguments, those can be specified upfront in your package.json file.

For example, given the below package.json file:

{
    "scripts": {
        "test": "jest",
        "test:coverage": "npm run test -- --coverage",
        "lint": "eslint 'src/*'",
        "start": "pm2 start server.js --port=3000",
        "ci": "failsafe start lint test:coverage"
    }
}

Running: npm run ci will execute:

  • npm run start
  • npm run lint
  • npm run test:coverage, in that order

It will also return the highest exit code of all the executed scripts.

Configuring Failsafe at runtime