fix: Use default plugin if the path property is missing from a single plugin configuration
This commit is contained in:
@@ -1,17 +1,12 @@
|
||||
const {isString, isObject, isFunction, isArray} = require('lodash');
|
||||
const semver = require('semver');
|
||||
const conditionTravis = require('@semantic-release/condition-travis');
|
||||
const commitAnalyzer = require('@semantic-release/commit-analyzer');
|
||||
const releaseNotesGenerator = require('@semantic-release/release-notes-generator');
|
||||
const npm = require('@semantic-release/npm');
|
||||
const github = require('@semantic-release/github');
|
||||
|
||||
const RELEASE_TYPE = ['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease'];
|
||||
const validatePluginConfig = conf => isString(conf) || isString(conf.path) || isFunction(conf);
|
||||
|
||||
module.exports = {
|
||||
verifyConditions: {
|
||||
default: [npm.verifyConditions, github.verifyConditions, conditionTravis],
|
||||
default: ['@semantic-release/npm', '@semantic-release/github', '@semantic-release/condition-travis'],
|
||||
config: {
|
||||
validator: conf => !conf || (isArray(conf) ? conf : [conf]).every(conf => validatePluginConfig(conf)),
|
||||
message:
|
||||
@@ -19,7 +14,7 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
getLastRelease: {
|
||||
default: npm.getLastRelease,
|
||||
default: '@semantic-release/npm',
|
||||
config: {
|
||||
validator: conf => Boolean(conf) && validatePluginConfig(conf),
|
||||
message:
|
||||
@@ -35,7 +30,7 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
analyzeCommits: {
|
||||
default: commitAnalyzer,
|
||||
default: '@semantic-release/commit-analyzer',
|
||||
config: {
|
||||
validator: conf => Boolean(conf) && validatePluginConfig(conf),
|
||||
message:
|
||||
@@ -55,7 +50,7 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
generateNotes: {
|
||||
default: releaseNotesGenerator,
|
||||
default: '@semantic-release/release-notes-generator',
|
||||
config: {
|
||||
validator: conf => !conf || validatePluginConfig(conf),
|
||||
message:
|
||||
@@ -67,7 +62,7 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
publish: {
|
||||
default: [npm.publish, github.publish],
|
||||
default: ['@semantic-release/npm', '@semantic-release/github'],
|
||||
config: {
|
||||
validator: conf => Boolean(conf) && (isArray(conf) ? conf : [conf]).every(conf => validatePluginConfig(conf)),
|
||||
message:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const {isArray} = require('lodash');
|
||||
const {isArray, isObject} = require('lodash');
|
||||
const DEFINITIONS = require('./definitions');
|
||||
const pipeline = require('./pipeline');
|
||||
const normalize = require('./normalize');
|
||||
@@ -8,6 +8,10 @@ module.exports = (options, logger) =>
|
||||
const {config, output, default: def} = DEFINITIONS[pluginType];
|
||||
let pluginConfs;
|
||||
if (options[pluginType]) {
|
||||
// If an object is passed and the path is missing, set the default one for single plugins
|
||||
if (isObject(options[pluginType]) && !options[pluginType].path && !isArray(def)) {
|
||||
options[pluginType].path = def;
|
||||
}
|
||||
if (config && !config.validator(options[pluginType])) {
|
||||
throw new Error(config.message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user