Skip to content
This repository was archived by the owner on Jan 14, 2018. It is now read-only.

Commit 3c5f4c1

Browse files
committed
fix(condition-travis): account for boolean env vars being strings
BREAKING CHANGE: only works with stringified env values
1 parent 61541a8 commit 3c5f4c1

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
const SRError = require('@semantic-release/error')
22

33
module.exports = function (options, pkg, argv, env, cb) {
4-
if (!env.TRAVIS) return cb(new SRError('Not running on Travis', 'ENOTRAVIS'))
4+
if (env.TRAVIS !== 'true') return cb(new SRError('Not running on Travis', 'ENOTRAVIS'))
55

6-
if (env.TRAVIS_PULL_REQUEST) return cb(new SRError('Not publishing from pull requests', 'EPULLREQUEST'))
6+
if (env.hasOwnProperty('TRAVIS_PULL_REQUEST') && env.TRAVIS_PULL_REQUEST !== 'false') return cb(new SRError('Not publishing from pull requests', 'EPULLREQUEST'))
77
if (env.TRAVIS_TAG) return cb(new SRError('Not publishing from tags', 'EGITTAG'))
88

99
const branch = (pkg.release || {}).branch || 'master'

test/specs/index.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ test('raise errors in travis environment', (t) => {
1616
t.test('not running on pull requests', (tt) => {
1717
tt.plan(2)
1818
condition({}, {}, {}, {
19-
TRAVIS: true,
20-
TRAVIS_PULL_REQUEST: true
19+
TRAVIS: 'true',
20+
TRAVIS_PULL_REQUEST: '105'
2121
}, (err) => {
2222
tt.ok(err instanceof SRError)
2323
tt.is(err.code, 'EPULLREQUEST')
@@ -27,8 +27,9 @@ test('raise errors in travis environment', (t) => {
2727
t.test('not running on tags', (tt) => {
2828
tt.plan(2)
2929
condition({}, {}, {}, {
30-
TRAVIS: true,
31-
TRAVIS_TAG: true
30+
TRAVIS: 'true',
31+
TRAVIS_PULL_REQUEST: 'false',
32+
TRAVIS_TAG: 'v1.0.0'
3233
}, (err) => {
3334
tt.ok(err instanceof SRError)
3435
tt.is(err.code, 'EGITTAG')
@@ -39,14 +40,14 @@ test('raise errors in travis environment', (t) => {
3940
tt.plan(5)
4041

4142
condition({}, {}, {}, {
42-
TRAVIS: true,
43+
TRAVIS: 'true',
4344
TRAVIS_BRANCH: 'master'
4445
}, (err) => {
4546
tt.is(err, null)
4647
})
4748

4849
condition({}, {}, {}, {
49-
TRAVIS: true,
50+
TRAVIS: 'true',
5051
TRAVIS_BRANCH: 'notmaster'
5152
}, (err) => {
5253
tt.ok(err instanceof SRError)
@@ -58,7 +59,7 @@ test('raise errors in travis environment', (t) => {
5859
branch: 'foo'
5960
}
6061
}, {}, {
61-
TRAVIS: true,
62+
TRAVIS: 'true',
6263
TRAVIS_BRANCH: 'master'
6364
}, (err) => {
6465
tt.ok(err instanceof SRError)
@@ -70,7 +71,7 @@ test('raise errors in travis environment', (t) => {
7071
tt.plan(5)
7172

7273
condition({}, {}, {}, {
73-
TRAVIS: true,
74+
TRAVIS: 'true',
7475
TRAVIS_BRANCH: 'master',
7576
BUILD_LEADER: 'YES',
7677
BUILD_AGGREGATE_STATUS: 'others_succeeded'
@@ -79,7 +80,7 @@ test('raise errors in travis environment', (t) => {
7980
})
8081

8182
condition({}, {}, {}, {
82-
TRAVIS: true,
83+
TRAVIS: 'true',
8384
TRAVIS_BRANCH: 'master',
8485
BUILD_LEADER: 'NO'
8586
}, (err) => {
@@ -88,7 +89,7 @@ test('raise errors in travis environment', (t) => {
8889
})
8990

9091
condition({}, {}, {}, {
91-
TRAVIS: true,
92+
TRAVIS: 'true',
9293
TRAVIS_BRANCH: 'master',
9394
BUILD_LEADER: 'YES',
9495
BUILD_AGGREGATE_STATUS: 'others_failed'

0 commit comments

Comments
 (0)