npm posttest doesn't trigger if npm test fails

前端 未结 1 1888
无人共我
无人共我 2021-02-15 07:11

Is there a way to trigger npm\'s posttest when test fails? If package.json contains

\"scripts\": {
  \"pretest\": \"echo pretest\",
  \"test\": \"some_failed_te         


        
1条回答
  •  盖世英雄少女心
    2021-02-15 08:02

    Worked it out. Not sure if the following will work in Windows. The bash || operator followed by an empty comment : changes the exit code.

    For instance, using mocha:

    "scripts": {
      "pretest": "echo pretest",
      "test": "mocha || :",
      "posttest": "echo posttest"
    }
    

    0 讨论(0)
提交回复
热议问题