Skip to content

Commit

Permalink
feat: add support for Cloudflare Pages
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandrHovhannisyan authored Jan 13, 2025
1 parent ae7d0a9 commit 75c9de8
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Officially supported CI servers:
| [Buildkite](https://buildkite.com) | `ci.BUILDKITE` ||
| [CircleCI](http://circleci.com) | `ci.CIRCLE` ||
| [Cirrus CI](https://cirrus-ci.org) | `ci.CIRRUS` ||
| [Cloudflare Pages](https://pages.cloudflare.com/) | `ci.CLOUDFLARE_PAGES` | 🚫 |
| [Codefresh](https://codefresh.io/) | `ci.CODEFRESH` ||
| [Codeship](https://codeship.com) | `ci.CODESHIP` | 🚫 |
| [Drone](https://drone.io) | `ci.DRONE` ||
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const BUDDY: boolean;
export const BUILDKITE: boolean;
export const CIRCLE: boolean;
export const CIRRUS: boolean;
export const CLOUDFLARE_PAGES: boolean;
export const CODEFRESH: boolean;
export const CODEMAGIC: boolean;
export const CODESHIP: boolean;
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ exports.isCI = !!(
env.CI !== 'false' && // Bypass all checks if CI env is explicitly set to 'false'
(env.BUILD_ID || // Jenkins, Cloudbees
env.BUILD_NUMBER || // Jenkins, TeamCity
env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari
env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari, Cloudflare Pages
env.CI_APP_ID || // Appflow
env.CI_BUILD_ID || // Appflow
env.CI_BUILD_NUMBER || // Appflow
Expand Down
19 changes: 19 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,25 @@ test('Cirrus CI - Not PR', function (t) {
t.end()
})

test('Cloudflare Pages - Not PR', function (t) {
// https://developers.cloudflare.com/pages/configuration/build-configuration/#environment-variables
process.env.CF_PAGES = '1'

clearModule('./')
const ci = require('./')

t.equal(ci.isCI, true)
t.equal(ci.isPR, null)
t.equal(ci.name, 'Cloudflare Pages')
t.equal(ci.CLOUDFLARE_PAGES, true)
t.equal(ci.id, 'CLOUDFLARE_PAGES')
assertVendorConstants('CLOUDFLARE_PAGES', ci, t)

delete process.env.CF_PAGES

t.end()
})

test('Codefresh - PR', function (t) {
process.env.CF_BUILD_ID = 'true'
process.env.CF_PULL_REQUEST_ID = '42'
Expand Down
5 changes: 5 additions & 0 deletions vendors.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@
"env": "CIRRUS_CI",
"pr": "CIRRUS_PR"
},
{
"name": "Cloudflare Pages",
"constant": "CLOUDFLARE_PAGES",
"env": "CF_PAGES"
},
{
"name": "Codefresh",
"constant": "CODEFRESH",
Expand Down

0 comments on commit 75c9de8

Please sign in to comment.