How can I write multiline scripts in npm scripts?

后端 未结 3 963
温柔的废话
温柔的废话 2021-02-06 20:37

My package.json looks like the following:

{
  \"name\": \"project\",
  \"version\": \"1.0.0\",
  \"description\": \"\",
  \"main\": \"server.js\",
  \"scripts\":         


        
3条回答
  •  南旧
    南旧 (楼主)
    2021-02-06 20:52

    You can chain independent tasks.

    Here is an example:

    "scripts": {
        "lint-jshint": "jshint --verbose --show-non-errors ./src/main/js",
        "lint-eslint": "eslint ./src/main/js ./src/test/js",
        "lint-csslint": "csslint ./src/main/js",
    
        "lint": "npm run -s lint-jshint & npm run -s lint-eslint & npm run -s lint-csslint",
    
        "pretest": "rimraf ./build/reports/tests && mkdirp ./build/reports/tests && npm run -s lint",
        "test": "karma start ./src/test/resources/conf/karma.conf.js",
        ...
    

    Here is a nice blog which I used at that time: https://www.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool/

提交回复
热议问题