Skip to content

Commit e438266

Browse files
authored
feat: add cloudlfare workers (#138)
1 parent 54b0343 commit e438266

5 files changed

Lines changed: 27 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Officially supported CI servers:
4747
| [CircleCI](http://circleci.com) | `ci.CIRCLE` ||
4848
| [Cirrus CI](https://cirrus-ci.org) | `ci.CIRRUS` ||
4949
| [Cloudflare Pages](https://pages.cloudflare.com/) | `ci.CLOUDFLARE_PAGES` | 🚫 |
50+
| [Cloudflare Workers](https://pages.cloudflare.com/) | `ci.CLOUDFLARE_WORKERS` | 🚫 |
5051
| [Codefresh](https://codefresh.io/) | `ci.CODEFRESH` ||
5152
| [Codeship](https://codeship.com) | `ci.CODESHIP` | 🚫 |
5253
| [Drone](https://drone.io) | `ci.DRONE` ||

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export const BUILDKITE: boolean;
4545
export const CIRCLE: boolean;
4646
export const CIRRUS: boolean;
4747
export const CLOUDFLARE_PAGES: boolean;
48+
export const CLOUDFLARE_WORKERS: boolean;
4849
export const CODEFRESH: boolean;
4950
export const CODEMAGIC: boolean;
5051
export const CODESHIP: boolean;

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ exports.isCI = !!(
3636
env.CI !== 'false' && // Bypass all checks if CI env is explicitly set to 'false'
3737
(env.BUILD_ID || // Jenkins, Cloudbees
3838
env.BUILD_NUMBER || // Jenkins, TeamCity
39-
env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari, Cloudflare Pages
39+
env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari, Cloudflare Pages/Workers
4040
env.CI_APP_ID || // Appflow
4141
env.CI_BUILD_ID || // Appflow
4242
env.CI_BUILD_NUMBER || // Appflow

test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,25 @@ test('Cloudflare Pages - Not PR', function (t) {
348348
t.end()
349349
})
350350

351+
test('Cloudflare Workers - Not PR', function (t) {
352+
// https://developers.cloudflare.com/pages/configuration/build-configuration/#environment-variables
353+
process.env.WORKERS_CI = '1'
354+
355+
clearModule('./')
356+
const ci = require('./')
357+
358+
t.equal(ci.isCI, true)
359+
t.equal(ci.isPR, null)
360+
t.equal(ci.name, 'Cloudflare Workers')
361+
t.equal(ci.CLOUDFLARE_WORKERS, true)
362+
t.equal(ci.id, 'CLOUDFLARE_WORKERS')
363+
assertVendorConstants('CLOUDFLARE_WORKERS', ci, t)
364+
365+
delete process.env.WORKERS_CI
366+
367+
t.end()
368+
})
369+
351370
test('Codefresh - PR', function (t) {
352371
process.env.CF_BUILD_ID = 'true'
353372
process.env.CF_PULL_REQUEST_ID = '42'

vendors.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@
9090
"constant": "CLOUDFLARE_PAGES",
9191
"env": "CF_PAGES"
9292
},
93+
{
94+
"name": "Cloudflare Workers",
95+
"constant": "CLOUDFLARE_WORKERS",
96+
"env": "WORKERS_CI"
97+
},
9398
{
9499
"name": "Codefresh",
95100
"constant": "CODEFRESH",

0 commit comments

Comments
 (0)