diff --git a/src/lib/verify.js b/src/lib/verify.js new file mode 100644 index 00000000..e1fb4299 --- /dev/null +++ b/src/lib/verify.js @@ -0,0 +1,37 @@ +const SemanticReleaseError = require('./error') + +module.exports = function (pkg, options, env) { + let 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) return errors + + if (!options['github-token']) { + errors.push(new SemanticReleaseError( + 'No github token specified.', + 'ENOGHTOKEN' + )) + } + + if (!env.NPM_TOKEN) { + errors.push(new SemanticReleaseError( + 'No npm token specified.', + 'ENONPMTOKEN' + )) + } + + return errors +}