From 5f8e4d467d90e304006c9ad6cf3d12c55c4ceb0e Mon Sep 17 00:00:00 2001 From: Jonas Gierer Date: Sat, 2 Mar 2019 11:31:08 +0100 Subject: [PATCH 1/3] Add test for Heroku --- test.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test.js b/test.js index c6185c0..1aadc6e 100644 --- a/test.js +++ b/test.js @@ -273,6 +273,23 @@ test('Cirrus CI - Not PR', function (t) { t.end() }) +test('Heroku - Not PR', function (t) { + process.env.NODE = '/app/.heroku/node/bin/node' + + clearModule('./') + var ci = require('./') + + t.equal(ci.isCI, true) + t.equal(ci.isPR, null) + t.equal(ci.name, 'Heroku') + t.equal(ci.HEROKU, true) + assertVendorConstants('HEROKU', ci, t) + + delete process.env.NODE + + t.end() +}) + test('Semaphore - PR', function (t) { process.env.SEMAPHORE = 'true' process.env.PULL_REQUEST_NUMBER = '42' From d6e1066324d542b456681f9bd1d1b584e02436af Mon Sep 17 00:00:00 2001 From: Jonas Gierer Date: Sat, 2 Mar 2019 11:31:34 +0100 Subject: [PATCH 2/3] Support Heroku --- index.js | 11 +++++++++++ vendors.json | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/index.js b/index.js index 9928fee..fb1879a 100644 --- a/index.js +++ b/index.js @@ -12,6 +12,10 @@ Object.defineProperty(exports, '_vendors', { exports.name = null exports.isPR = null +function includes (str, search) { + return !!~str.indexOf(search) +} + vendors.forEach(function (vendor) { var envs = Array.isArray(vendor.env) ? vendor.env : [vendor.env] var isCI = envs.every(function (obj) { @@ -60,6 +64,13 @@ exports.isCI = !!( function checkEnv (obj) { if (typeof obj === 'string') return !!env[obj] + + if ('env' in obj) { + // { env: "NODE", includes: "heroku" } + return obj.env in env && includes(env[obj.env], obj.includes) + } + + // { "CI_NAME": "codeship" } return Object.keys(obj).every(function (k) { return env[k] === obj[k] }) diff --git a/vendors.json b/vendors.json index 266a724..43cb0cf 100644 --- a/vendors.json +++ b/vendors.json @@ -83,6 +83,11 @@ "constant": "GOCD", "env": "GO_PIPELINE_LABEL" }, + { + "name": "Heroku", + "constant": "HEROKU", + "env": { "env": "NODE", "includes": "heroku" } + }, { "name": "Hudson", "constant": "HUDSON", From 32816bf5aaa1e545c97966f5565b51b80b810758 Mon Sep 17 00:00:00 2001 From: Jonas Gierer Date: Sat, 2 Mar 2019 11:35:59 +0100 Subject: [PATCH 3/3] Update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 12c4f62..fe54cef 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ Officially supported CI servers: | [dsari](https://github.com/rfinnie/dsari) | `ci.DSARI` | 🚫 | | [GitLab CI](https://about.gitlab.com/gitlab-ci/) | `ci.GITLAB` | 🚫 | | [GoCD](https://www.go.cd/) | `ci.GOCD` | 🚫 | +| [Heroku](https://www.heroku.com) | `ci.HEROKU` | 🚫 | | [Hudson](http://hudson-ci.org) | `ci.HUDSON` | 🚫 | | [Jenkins CI](https://jenkins-ci.org) | `ci.JENKINS` | ✅ | | [Magnum CI](https://magnum-ci.com) | `ci.MAGNUM` | 🚫 |