Skip to content

Commit 34030b7

Browse files
Documented the new host.ci property
1 parent db5eb6b commit 34030b7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Host Environment is a [universal JavaScript](https://medium.com/@mjackson/univer
1919
- Is this Node 8.x or newer?
2020
- Are we in Internet Explorer?
2121
- Is this a Windows computer?
22+
- Are we running in a CI/CD environment?
2223

2324
Maybe some parts of your app are only available in Node and not in web browsers. Or maybe you need to determine whether to load a [polyfill](https://en.wikipedia.org/wiki/Polyfill_(programming)) library. Or maybe you need to [conditionally run tests](https://jstools.dev/karma-host-environment/) in different environments. Whatever your reason, Host Environment can help.
2425

@@ -136,6 +137,20 @@ When running in a web browser, it is usually an empty object, since web browsers
136137
```
137138

138139

140+
### `host.ci`
141+
When running on a [known CI/CD host](https://www.npmjs.com/package/@qawolf/ci-info#supported-ci-tools), this property is an object containing informaation about the CI/CD host and the job that's being run.
142+
143+
When running outside of a CI/CD host, this property is `false`. Since CI/CD hosts are detected based on the presence of environment variables, this property will usually be `false` when running in a web browser (where environment variables aren't accessible). However, when paired with tools like [karma-host-environment](https://jstools.dev/karma-host-environment/), it's possible to work-around this limitation and allow you to access CI/CD information in the browser.
144+
145+
```javascript
146+
{
147+
name: "Travis CI", // The name of the CI/CD host
148+
TRAVIS: true, // The CI/CD host as a boolean
149+
pr: true, // Whether the CI/CD job was triggered by a pull-request
150+
}
151+
```
152+
153+
139154
### `host.node`
140155
This property is `false` when running in a web browser. When running in Node.js it is an object with the following structure:
141156

0 commit comments

Comments
 (0)