Skip to content

Commit 92c69b8

Browse files
committed
feat(type): Add support for rskip
Add support for rskip release type, and skipping releases. Skipping releases is supported by semantic-release/commit-analyzer#2. Fixes semantic-release#41
1 parent 98896ef commit 92c69b8

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/lib/type.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// TODO: Test, update commit-analyzer
1+
// TODO: Test
22
const SemanticReleaseError = require('@semantic-release/error')
33
const _ = require('lodash')
44

@@ -15,6 +15,13 @@ module.exports = function (config, cb) {
1515
))
1616
}
1717

18+
if (type === 'rskip') {
19+
return cb(new SemanticReleaseError(
20+
'The release was skipped',
21+
'ERELSKIP'
22+
))
23+
}
24+
1825
if (!lastRelease.version) return cb(null, 'initial')
1926

2027
cb(null, type)
@@ -34,6 +41,8 @@ function parseCommits (parse, config, commits, cb) {
3441
if (type < t) type = t
3542

3643
if (i === 0) {
44+
if (t === 'rskip') return cb(null, t)
45+
3746
let out = types[type]
3847
if (out === types[0]) out = false
3948
return cb(null, out)

test/specs/type.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const test = require('tap').test
33
const type = require('../../dist/lib/type')
44

55
test('get type from commits', (t) => {
6-
t.plan(4)
6+
t.plan(5)
77

88
t.test('get type from plugin', (tt) => {
99
tt.plan(2)
@@ -78,5 +78,17 @@ test('get type from commits', (t) => {
7878
})
7979
})
8080

81+
t.test('error when skipped', (tt) => {
82+
tt.plan(1)
83+
84+
type({
85+
commits: [],
86+
lastRelease: {},
87+
plugins: {analyzeCommits: (config, cb) => cb(null, 'rskip')}
88+
}, (err) => {
89+
tt.is(err.code, 'ERELSKIP')
90+
})
91+
})
92+
8193
t.end()
8294
})

0 commit comments

Comments
 (0)