fix(verify): ensure repo url in package.json is well formed
This commit is contained in:
		
							parent
							
								
									dbea5cc1b1
								
							
						
					
					
						commit
						431babb42e
					
				| @ -1,3 +1,5 @@ | ||||
| const parseSlug = require('parse-github-repo-url') | ||||
| 
 | ||||
| const SemanticReleaseError = require('@semantic-release/error') | ||||
| 
 | ||||
| module.exports = function (pkg, options, env) { | ||||
| @ -15,6 +17,11 @@ module.exports = function (pkg, options, env) { | ||||
|       'No "repository" found in package.json.', | ||||
|       'ENOPKGREPO' | ||||
|     )) | ||||
|   } else if (!parseSlug(pkg.repository.url)) { | ||||
|     errors.push(new SemanticReleaseError( | ||||
|       'The "repository" field in the package.json is malformed.', | ||||
|       'EMALFORMEDPKGREPO' | ||||
|     )) | ||||
|   } | ||||
| 
 | ||||
|   if (options.debug) return errors | ||||
|  | ||||
| @ -23,6 +23,18 @@ test('verify pkg, options and env', (t) => { | ||||
|     tt.is(errors[0].code, 'ENOPKGNAME') | ||||
|     tt.is(errors[1].code, 'ENOPKGREPO') | ||||
| 
 | ||||
|     const errors2 = verify({ | ||||
|       name: 'package', | ||||
|       repository: { | ||||
|         url: 'lol' | ||||
|       } | ||||
|     }, { | ||||
|       debug: true | ||||
|     }, {}) | ||||
| 
 | ||||
|     tt.is(errors2.length, 1) | ||||
|     tt.is(errors2[0].code, 'EMALFORMEDPKGREPO') | ||||
| 
 | ||||
|     tt.end() | ||||
|   }) | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user