https://github.com/watson/ci-info を使うと便利。
様々な CI サービスがそれぞれ使っている環境変数とかを見て自分が CI にいるのか否かを判定してくれる。
var ci = require('ci-info')
if (ci.isCI) {
console.log('The name of the CI server is:', ci.name)
} else {
console.log('This program is not running on a CI server')
}
https://sosukesuzuki.dev/posts/transfer-my-repo-to-oss-org/ とかで紹介した https://prettier/prettier-regression-testing は基本的に GitHub Actions で動かすことを想定しているが CLI からも叩くことができるようにしたかったのでその分岐のために使った。
あと Prettier 本体でも使ってる。