30秒学会 JavaScript 片段 · 2018年12月7日

30秒学会 JavaScript 片段 – isTravisCI

Checks if the current environment is Travis CI.

Checks if the current environment has the TRAVIS and CI environment variables (reference).

代码片段

const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env;

使用样例

isTravisCI(); // true (if code is running on Travis CI)