Skip to content

Commit 869cb5a

Browse files
committed
[update] add increase function
1 parent f6133f2 commit 869cb5a

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
language: node_js
2+
node_js:
3+
- '9'
4+
- '8'
5+
- '6'
6+
script:
7+
- 'npm test'
8+
after_success:
9+
- 'npm install coveralls && npm install nyc && ./node_modules/.bin/nyc report --temp-directory=coverage --reporter=text-lcov | ./node_modules/.bin/coveralls'
10+
notifications:
11+
webhooks:
12+
urls:
13+
- 'https://www.travisbuddy.com/'
14+
on_success: never
15+
on_failure: always
16+
on_start: never
17+
on_cancel: never
18+
on_error: never

__tests__/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,13 @@ describe('base test', () => {
7878
expect(() => helper.getLatest(123)).toThrow('prefix must be RegExp or String, but not number');
7979
});
8080
});
81+
82+
describe('increase', () => {
83+
test('normal use', () => {
84+
expect(helper.increase('dev-v')).toBe('0.1.4');
85+
expect(helper.increase('dev-v', 'minor')).toBe('0.2.0');
86+
expect(helper.increase('dev-v', 'major')).toBe('1.0.0');
87+
expect(helper.increase()).toBe(null);
88+
});
89+
});
8190
});

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ class Helper {
9191

9292
return obj.version;
9393
}
94+
95+
increase(prefix = '', type = 'patch') {
96+
const latest_semver = this.getLatest(prefix, { semver: true });
97+
return semver.inc(latest_semver, type);
98+
}
9499
}
95100

96101
module.exports = new Helper();

0 commit comments

Comments
 (0)