chore: reuse parsing expression
This commit is contained in:
Родитель
4733b6bb72
Коммит
6c2fb064e0
|
@ -2,6 +2,7 @@ const analyzeCommits = require('@semantic-release/commit-analyzer')
|
|||
const SemanticReleaseError = require('@semantic-release/error')
|
||||
const execSync = require('child_process').execSync;
|
||||
const lastTag = require('./lastTag');
|
||||
const utils = require('./utils');
|
||||
|
||||
const until = f => array => {
|
||||
const first = array[0];
|
||||
|
@ -23,7 +24,7 @@ const lastTaggedRelease = () => {
|
|||
module.exports = function (pluginConfig, config, cb) {
|
||||
// run standard commit analysis
|
||||
return analyzeCommits(pluginConfig, config, function(error, type) {
|
||||
const branch = config.env.TRAVIS_BRANCH || config.env.GIT_LOCAL_BRANCH || config.env.GITHUB_REF.split('/').slice(-1)[0];
|
||||
const branch = config.env.TRAVIS_BRANCH || config.env.GIT_LOCAL_BRANCH || utils.ghParseBranch(config.env.GITHUB_REF);
|
||||
const branchTags = config.options.branchTags;
|
||||
const distTag = branchTags && branchTags[branch];
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const defaultLastRelease = require('@semantic-release/last-release-npm');
|
||||
const lastTag = require('./lastTag');
|
||||
|
||||
const utils = require('./utils');
|
||||
module.exports = function (pluginConfig, config, cb) {
|
||||
let branch;
|
||||
let oldTag;
|
||||
|
@ -8,7 +8,7 @@ module.exports = function (pluginConfig, config, cb) {
|
|||
if (config.env.TRAVIS) {
|
||||
branch = config.env.TRAVIS_BRANCH;
|
||||
} else if (config.env.GITHUB_REF) {
|
||||
branch = config.env.GITHUB_REF.split('/').slice(-1)[0];
|
||||
branch = utils.ghParseBranch(config.env.GITHUB_REF);
|
||||
} else {
|
||||
branch = config.env.GIT_LOCAL_BRANCH;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
let utils = {};
|
||||
|
||||
utils.ghParseBranch = branch => branch.split('/').slice(-1)[0];
|
||||
|
||||
module.exports = utils;
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
const utils = require('./utils');
|
||||
|
||||
module.exports = function (pluginConfig, config, cb) {
|
||||
let branch;
|
||||
let defaultVerifyConditions;
|
||||
|
@ -7,7 +9,7 @@ module.exports = function (pluginConfig, config, cb) {
|
|||
branch = config.env.TRAVIS_BRANCH;
|
||||
} else if (config.env.GITHUB_REF) {
|
||||
defaultVerifyConditions = require('condition-github-actions');
|
||||
branch = config.env.GITHUB_REF.split('/').slice(-1)[0];
|
||||
branch = utils.ghParseBranch(config.env.GITHUB_REF);
|
||||
} else {
|
||||
defaultVerifyConditions = require('@krux/condition-jenkins');
|
||||
branch = config.env.GIT_LOCAL_BRANCH;
|
||||
|
|
Загрузка…
Ссылка в новой задаче