feat(cli): add verifyConditions hook
This commit is contained in:
		
							parent
							
								
									af15fb4c61
								
							
						
					
					
						commit
						13e2f5ce78
					
				| @ -15,6 +15,7 @@ | ||||
|   }, | ||||
|   "dependencies": { | ||||
|     "@semantic-release/commit-analyzer": "^1.0.0", | ||||
|     "@semantic-release/condition-travis": "^1.0.0", | ||||
|     "@semantic-release/error": "^1.0.0", | ||||
|     "@semantic-release/release-notes-generator": "^1.0.0", | ||||
|     "lodash": "^3.9.3", | ||||
|  | ||||
							
								
								
									
										25
									
								
								src/index.js
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								src/index.js
									
									
									
									
									
								
							| @ -31,6 +31,8 @@ npmconf.load({}, (err, conf) => { | ||||
| 
 | ||||
|   log.level = conf.get('loglevel') | ||||
| 
 | ||||
|   log.verbose(PREFIX, 'argv:', options) | ||||
|   log.verbose(PREFIX, 'options:', pkg.release || 'no options') | ||||
|   log.verbose(PREFIX, 'Verifying pkg, options and env.') | ||||
| 
 | ||||
|   const errors = require('./lib/verify')(pkg, options, env) | ||||
| @ -39,6 +41,13 @@ npmconf.load({}, (err, conf) => { | ||||
| 
 | ||||
|   if (!options.argv.cooked.length || options.argv.cooked[0] === 'pre') { | ||||
|     log.verbose(PREFIX, 'Running pre-script.') | ||||
|     log.verbose(PREFIX, 'Veriying conditions.') | ||||
| 
 | ||||
|     plugins.verifyConditions(pkg, options, env, (err) => { | ||||
|       if (err) { | ||||
|         log[options.debug ? 'warn' : 'error'](PREFIX, err.message) | ||||
|         if (!options.debug) process.exit(1) | ||||
|       } | ||||
| 
 | ||||
|       const registry = conf.get('registry') | ||||
|       const nerfDart = require('./lib/nerf-dart')(registry) | ||||
| @ -49,7 +58,7 @@ npmconf.load({}, (err, conf) => { | ||||
|         wroteNpmRc = true | ||||
|       } else if (env.NPM_OLD_TOKEN && env.NPM_EMAIL) { | ||||
|         // Using the old auth token format is not considered part of the public API
 | ||||
|       // This might go away anytime (i.e. when we have a better testing strategy)
 | ||||
|         // This might go away anytime (i.e. once we have a better testing strategy)
 | ||||
|         conf.set('_auth', '${NPM_OLD_TOKEN}', 'project') | ||||
|         conf.set('email', '${NPM_EMAIL}', 'project') | ||||
|         wroteNpmRc = true | ||||
| @ -78,17 +87,19 @@ npmconf.load({}, (err, conf) => { | ||||
|             process.exit(1) | ||||
|           } | ||||
| 
 | ||||
|         log.verbose(PREFIX, `Determined version ${release.version}.`, release) | ||||
|           log.verbose(PREFIX, `Determined version ${release.version}.`) | ||||
| 
 | ||||
|           if (options.debug) { | ||||
|             log.error(PREFIX, `Determined version ${release.version}, but not publishing in debug mode.`, release) | ||||
|             process.exit(1) | ||||
|           } | ||||
| 
 | ||||
|           writeFileSync('./package.json', JSON.stringify(_.assign(pkg, { | ||||
|             version: release.version | ||||
|           }), null, 2)) | ||||
| 
 | ||||
|         log.info(PREFIX, `Wrote version ${release.version} to package.json.`) | ||||
|         if (options.debug) { | ||||
|           log.error(PREFIX, 'Not publishing in debug mode') | ||||
|           process.exit(1) | ||||
|         } | ||||
|           log.verbose(PREFIX, `Wrote version ${release.version} to package.json.`) | ||||
|         }) | ||||
|       }) | ||||
|     }) | ||||
|   } else if (options.argv.cooked[0] === 'post') { | ||||
|  | ||||
| @ -4,6 +4,7 @@ let exports = module.exports = function (source) { | ||||
|   return { | ||||
|     analyzeCommits: exports.normalize(source.analyzeCommits, '@semantic-release/commit-analyzer'), | ||||
|     generateNotes: exports.normalize(source.generateNotes, '@semantic-release/release-notes-generator'), | ||||
|     verifyConditions: exports.normalize(source.verifyCondition, '@semantic-release/condition-travis'), | ||||
|     verifyRelease: exports.normalize(source.verifyRelease, './plugin-noop') | ||||
|   } | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user