最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - npm run tests before build - Stack Overflow

programmeradmin3浏览0评论

I recently discovered the npm version [major|minor|patch] mand to automatically bump the package version number and mit the changes. This was a magical little discovery.

Is it possible to run tests prior to the bump & git mit with npm? Trying to avoid having to write a bash script.

I can't find anything on google or stack search "npm version ....." matches too many unrelated results. And there is no info about testing in the docs npm-version

I was begging to write a script before this discovery. To test, bump version, then git mit.

I'm using karma, package.json contains

"scripts": {
    "test": "karma run"
}

While testing the npm version mand I added a failing test

it("force fail",function(){
    expect(true).toEqual(1);
});  

So karma run and npm test both result in a failed test run. I was hoping this would stop the version patch, but no luck. I managed to bump and mit with failing tests.

I recently discovered the npm version [major|minor|patch] mand to automatically bump the package version number and mit the changes. This was a magical little discovery.

Is it possible to run tests prior to the bump & git mit with npm? Trying to avoid having to write a bash script.

I can't find anything on google or stack search "npm version ....." matches too many unrelated results. And there is no info about testing in the docs npm-version

I was begging to write a script before this discovery. To test, bump version, then git mit.

I'm using karma, package.json contains

"scripts": {
    "test": "karma run"
}

While testing the npm version mand I added a failing test

it("force fail",function(){
    expect(true).toEqual(1);
});  

So karma run and npm test both result in a failed test run. I was hoping this would stop the version patch, but no luck. I managed to bump and mit with failing tests.

Share Improve this question asked Jul 2, 2014 at 3:07 LexLex 5,0444 gold badges48 silver badges70 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

Adding them to scripts could work, though I really would remend just defining a function in your shell’s runtime configuration.

"scripts": {
    "test": "karma run",
    "major": "karma run && npm version major && git mit",
    "minor": "karma run && npm version minor && git mit",
    "patch": "karma run && npm version patch && git mit"
}
发布评论

评论列表(0)

  1. 暂无评论