From b63a43fa535ec01a266f157b8c8e5f222eef1806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6nnemann?= Date: Wed, 17 Jun 2015 15:42:14 -0700 Subject: [PATCH] feat(verify): initial verification for pkg, options and env --- src/lib/verify.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/lib/verify.js 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 +}