[NPM] Run a set of similar npm scripts with a wildcard

In this lesson we will run a set of scripts that are grouped together with a wildcard using the npm-run-all node package. Using this technique can help you simplify and organize your scripts.css

 

Install:node

npm i -D npm-run-all

 

Instead of running 'eslint styleline mocha' by using npm-run-all:npm

    "test": "npm-run-all eslint stylelint mocha",
    "eslint": "eslint --cache --fix ./",
    "stylelint": "stylelint '**/*.scss' --syntax scss",

 

We actually can group scripts by features:less

    "test": "npm-run-all lint:* mocha","lint:js": "eslint --cache --fix ./",
    "lint:css": "stylelint '**/*.scss' --syntax scss",

Here 'lint:*' will match 'lint:js' and 'lint:css' both.this

 

Also we can do:spa

    "test": "npm-run-all lint mocha",
    "lint": "npm-run-all lint:**",
    "lint:js": "eslint --cache --fix ./",
    "lint:css": "stylelint '**/*.scss' --syntax scss",
    "lint:css:fix": "stylefmt -R src/"

Here 'lint:**' will match also two leavel deep ':' such as 'lint:css.fix'.eslint

 

PS: stylefmt lib will help to fix css if there is any lint error in css.code

相關文章
相關標籤/搜索