cross-ci
Version:
`cross-ci` standardizes environment variables for CI. For example, your can simply use `BUILD_BRANCH` variable in all CI runners instead of `CIRCLE_BRANCH` in CircleCI or `TRAVIS_PULL_REQUEST_BRANCH` in Travis.
32 lines (25 loc) • 701 B
JavaScript
const url = require('url');
const pkg = require('../pkg');
/// Git version control system used
const GIT_PLATFORM = ({CI_PLATFORM}) => {
if (process.env.GIT_PLATFORM) {
return process.env.GIT_PLATFORM;
}
if (CI_PLATFORM === 'gitlab') {
return 'gitlab';
}
try {
const hostname = new url.URL(pkg.repository.url).hostname;
switch (hostname) {
case 'github.com':
return 'github';
case 'bitbucket.org':
return 'bitbucket';
case 'gitlab.com':
return 'gitlab';
}
// eslint-disable-next-line no-empty
} catch (error) {}
return 'github';
};
module.exports = GIT_PLATFORM;