diff options
author | Audrey Eschright <audrey@npmjs.com> | 2018-11-29 14:05:52 -0800 |
---|---|---|
committer | Myles Borins <mylesborins@google.com> | 2019-05-16 14:56:07 -0400 |
commit | 391185e5503adc45fde8175961d6eab45fc8cc88 (patch) | |
tree | d25cd669d680620e5c7bbc622e0a4de355884194 /deps/npm/node_modules/ci-info/index.js | |
parent | 6014b476c3f001ee2a4f0e37493c5639ceae5cef (diff) | |
download | node-new-391185e5503adc45fde8175961d6eab45fc8cc88.tar.gz |
deps: upgrade npm to 6.5.0
PR-URL: https://github.com/nodejs/node/pull/24734
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'deps/npm/node_modules/ci-info/index.js')
-rw-r--r-- | deps/npm/node_modules/ci-info/index.js | 84 |
1 files changed, 46 insertions, 38 deletions
diff --git a/deps/npm/node_modules/ci-info/index.js b/deps/npm/node_modules/ci-info/index.js index 74750a7c06..27794d49b3 100644 --- a/deps/npm/node_modules/ci-info/index.js +++ b/deps/npm/node_modules/ci-info/index.js @@ -1,58 +1,66 @@ 'use strict' -var env = process.env +var vendors = require('./vendors.json') -var vendors = [ - // Constant, Name, Envs - ['APPVEYOR', 'AppVeyor', 'APPVEYOR'], - ['BAMBOO', 'Bamboo', 'bamboo_planKey'], - ['BITBUCKET', 'Bitbucket Pipelines', 'BITBUCKET_COMMIT'], - ['BUILDKITE', 'Buildkite', 'BUILDKITE'], - ['CIRCLE', 'CircleCI', 'CIRCLECI'], - ['CIRRUS', 'Cirrus CI', 'CIRRUS_CI'], - ['CODEBUILD', 'AWS CodeBuild', 'CODEBUILD_BUILD_ARN'], - ['CODESHIP', 'Codeship', {CI_NAME: 'codeship'}], - ['DRONE', 'Drone', 'DRONE'], - ['GITLAB', 'GitLab CI', 'GITLAB_CI'], - ['GOCD', 'GoCD', 'GO_PIPELINE_LABEL'], - ['HUDSON', 'Hudson', 'HUDSON_URL'], - ['JENKINS', 'Jenkins', 'JENKINS_URL', 'BUILD_ID'], - ['MAGNUM', 'Magnum CI', 'MAGNUM'], - ['SEMAPHORE', 'Semaphore', 'SEMAPHORE'], - ['SHIPPABLE', 'Shippable', 'SHIPPABLE'], - ['SOLANO', 'Solano CI', 'TDDIUM'], - ['STRIDER', 'Strider CD', 'STRIDER'], - ['TASKCLUSTER', 'TaskCluster', 'TASK_ID', 'RUN_ID'], - ['TDDIUM', 'Solano CI', 'TDDIUM'], // Deprecated - ['TEAMCITY', 'TeamCity', 'TEAMCITY_VERSION'], - ['TFS', 'Team Foundation Server', 'TF_BUILD'], - ['TRAVIS', 'Travis CI', 'TRAVIS'] -] +var env = process.env // Used for testinging only Object.defineProperty(exports, '_vendors', { - value: vendors.map(function (v) { return v[0] }) + value: vendors.map(function (v) { return v.constant }) }) exports.name = null +exports.isPR = null vendors.forEach(function (vendor) { - var constant = vendor.shift() - var name = vendor.shift() - var isCI = vendor.every(function (obj) { - if (typeof obj === 'string') return !!env[obj] - return Object.keys(obj).every(function (k) { - return env[k] === obj[k] - }) + var envs = Array.isArray(vendor.env) ? vendor.env : [vendor.env] + var isCI = envs.every(function (obj) { + return checkEnv(obj) }) - exports[constant] = isCI - if (isCI) exports.name = name + + exports[vendor.constant] = isCI + + if (isCI) { + exports.name = vendor.name + + switch (typeof vendor.pr) { + case 'string': + // "pr": "CIRRUS_PR" + exports.isPR = !!env[vendor.pr] + break + case 'object': + if ('env' in vendor.pr) { + // "pr": { "env": "BUILDKITE_PULL_REQUEST", "ne": "false" } + exports.isPR = vendor.pr.env in env && env[vendor.pr.env] !== vendor.pr.ne + } else if ('any' in vendor.pr) { + // "pr": { "any": ["ghprbPullId", "CHANGE_ID"] } + exports.isPR = vendor.pr.any.some(function (key) { + return !!env[key] + }) + } else { + // "pr": { "DRONE_BUILD_EVENT": "pull_request" } + exports.isPR = checkEnv(vendor.pr) + } + break + default: + // PR detection not supported for this vendor + exports.isPR = null + } + } }) exports.isCI = !!( - env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip + env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari env.CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI env.BUILD_NUMBER || // Jenkins, TeamCity + env.RUN_ID || // TaskCluster, dsari exports.name || false ) + +function checkEnv (obj) { + if (typeof obj === 'string') return !!env[obj] + return Object.keys(obj).every(function (k) { + return env[k] === obj[k] + }) +} |