- Use async/await instead of callbacks - Use execa to run command line - Use AVA for tests - Add several assertions in the unit tests - Add documentation (comments) in the tests - Run tests with a real git repo instead of mocking child_process and add test helpers to create repos, commits and checkout - Simplify test directory structure - Simplify code readability (mostly with async/await) - Use eslint for for linting, prettier for formatting
15 lines
442 B
JavaScript
15 lines
442 B
JavaScript
const {promisify} = require('util');
|
|
const SemanticReleaseError = require('@semantic-release/error');
|
|
|
|
module.exports = async config => {
|
|
const {plugins, lastRelease} = config;
|
|
const type = await promisify(plugins.analyzeCommits)(config);
|
|
|
|
if (!type) {
|
|
throw new SemanticReleaseError('There are no relevant changes, so no new version is released.', 'ENOCHANGE');
|
|
}
|
|
if (!lastRelease.version) return 'initial';
|
|
|
|
return type;
|
|
};
|