test(pre): verification hook
This commit is contained in:
		
							parent
							
								
									245f918201
								
							
						
					
					
						commit
						1f70215ffe
					
				| @ -5,6 +5,7 @@ var test = require('tape') | ||||
| var createModule = require('./lib/create-module') | ||||
| 
 | ||||
| require('./scenarios/custom-analyzer')(test, createModule) | ||||
| require('./scenarios/custom-verification')(test, createModule) | ||||
| require('./scenarios/ignore')(test, createModule) | ||||
| require('./scenarios/prepublish')(test, createModule) | ||||
| require('./scenarios/postpublish')(test, createModule) | ||||
|  | ||||
							
								
								
									
										5
									
								
								tests/lib/custom-verification.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								tests/lib/custom-verification.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,5 @@ | ||||
| 'use strict' | ||||
| 
 | ||||
| module.exports = function (opts, cb) { | ||||
|   cb(null, !(opts.commits.length % 2)) | ||||
| } | ||||
							
								
								
									
										45
									
								
								tests/scenarios/custom-verification.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								tests/scenarios/custom-verification.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,45 @@ | ||||
| 'use strict' | ||||
| 
 | ||||
| var path = require('path') | ||||
| 
 | ||||
| var efh = require('error-first-handler') | ||||
| var nixt = require('nixt') | ||||
| 
 | ||||
| module.exports = function (test, createModule) { | ||||
|   createModule({ | ||||
|     release: { | ||||
|       verification: path.join(__dirname, '../lib/custom-verification') | ||||
|     } | ||||
|   }, efh()(function (name, cwd) { | ||||
|     test('custom-verification', function (t) { | ||||
|       t.test('even commit count', function (t) { | ||||
|         t.plan(1) | ||||
|         nixt() | ||||
|           .cwd(cwd) | ||||
|           .env('CI', true) | ||||
|           .env('npm_config_registry', 'http://127.0.0.1:4873/') | ||||
|           .exec('git commit --allow-empty -m "feat: commit"') | ||||
|           .run('npm run prepublish') | ||||
|           .code(0) | ||||
|           .end(function (err) { | ||||
|             t.error(err, 'nixt') | ||||
|           }) | ||||
|       }) | ||||
| 
 | ||||
|       t.test('odd commit count', function (t) { | ||||
|         t.plan(1) | ||||
|         nixt() | ||||
|           .cwd(cwd) | ||||
|           .env('CI', true) | ||||
|           .env('npm_config_registry', 'http://127.0.0.1:4873/') | ||||
|           .exec('git commit --allow-empty -m "feat: commit"') | ||||
|           .run('npm run prepublish') | ||||
|           .code(1) | ||||
|           .stdout(/Verification failed/) | ||||
|           .end(function (err) { | ||||
|             t.error(err, 'nixt') | ||||
|           }) | ||||
|       }) | ||||
|     }) | ||||
|   })) | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user