-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(config): Rename
commitTypes
config to releaseRules
📦
BREAKING CHANGE: Configuration change: rename `commitTypes` to `releaseRules`
- Loading branch information
Showing
11 changed files
with
140 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const importCwd = require('import-cwd'); | ||
const SemanticReleaseError = require('@semantic-release/error'); | ||
const RELEASE_TYPES = require('../default/release-types'); | ||
|
||
/** | ||
* Load and validate the `releaseRules` rules. | ||
* | ||
* If `releaseRules` parameter is a `string` then load it as an external module with `require`. | ||
* Verifies that the loaded/parameter `releaseRules` is an `Array` and each element has a valid `release` attribute. | ||
* | ||
* @param {string|Array} releaseRules a string to load an external module or an `Array` of rules. | ||
* @return {Array} the loaded and validated `releaseRules`. | ||
*/ | ||
module.exports = ({releaseRules}) => { | ||
let loadedReleaseRules; | ||
|
||
if (releaseRules) { | ||
loadedReleaseRules = typeof releaseRules === 'string' ? importCwd(releaseRules) : releaseRules; | ||
|
||
if (!Array.isArray(loadedReleaseRules)) { | ||
throw new SemanticReleaseError( | ||
'Error in sr-commit-analyzer configuration: "releaseRules" must be an array of rules', | ||
'EINVALIDCONFIG' | ||
); | ||
} | ||
|
||
loadedReleaseRules.forEach(rule => { | ||
if (RELEASE_TYPES.indexOf(rule.release) === -1) { | ||
throw new SemanticReleaseError( | ||
`Error in sr-commit-analyzer configuration: "${rule.release}" is not a valid release type. Valid values are: ${JSON.stringify( | ||
RELEASE_TYPES | ||
)}`, | ||
'EINVALIDRELEASE' | ||
); | ||
} | ||
}); | ||
} | ||
return loadedReleaseRules; | ||
}; |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.