- 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
26 lines
739 B
JavaScript
26 lines
739 B
JavaScript
const SemanticReleaseError = require('@semantic-release/error');
|
|
|
|
module.exports = ({pkg, options, env}) => {
|
|
const errors = [];
|
|
|
|
if (!pkg.name) {
|
|
errors.push(new SemanticReleaseError('No "name" found in package.json.', 'ENOPKGNAME'));
|
|
}
|
|
|
|
if (!pkg.repository || !pkg.repository.url) {
|
|
errors.push(new SemanticReleaseError('No "repository" found in package.json.', 'ENOPKGREPO'));
|
|
}
|
|
|
|
if (!options.debug) {
|
|
if (!options.githubToken) {
|
|
errors.push(new SemanticReleaseError('No github token specified.', 'ENOGHTOKEN'));
|
|
}
|
|
|
|
if (!(env.NPM_TOKEN || (env.NPM_OLD_TOKEN && env.NPM_EMAIL))) {
|
|
errors.push(new SemanticReleaseError('No npm token specified.', 'ENONPMTOKEN'));
|
|
}
|
|
}
|
|
|
|
return errors;
|
|
};
|