feat(verify): initial verification for pkg, options and env

This commit is contained in:
Stephan Bönnemann 2015-06-17 15:42:14 -07:00
parent c47ff97ab3
commit b63a43fa53

37
src/lib/verify.js Normal file
View File

@ -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
}