fix: allow to set ci option via API and config file
				
					
				
			This commit is contained in:
		
							parent
							
								
									6b110b6e9e
								
							
						
					
					
						commit
						862ec4c087
					
				
							
								
								
									
										5
									
								
								cli.js
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								cli.js
									
									
									
									
									
								
							| @ -47,11 +47,6 @@ Usage: | ||||
|       return 0; | ||||
|     } | ||||
| 
 | ||||
|     // Set the `noCi` options as yargs sets the `ci` options instead (because arg starts with `--no`)
 | ||||
|     if (opts.ci === false) { | ||||
|       opts.noCi = true; | ||||
|     } | ||||
| 
 | ||||
|     if (opts.debug) { | ||||
|       // Debug must be enabled before other requires in order to work
 | ||||
|       require('debug').enable('semantic-release:*'); | ||||
|  | ||||
| @ -27,6 +27,9 @@ module.exports = async (context, opts) => { | ||||
| 
 | ||||
|   // Merge config file options and CLI/API options
 | ||||
|   let options = {...config, ...opts}; | ||||
|   if (options.ci === false) { | ||||
|     options.noCi = true; | ||||
|   } | ||||
|   const pluginsPath = {}; | ||||
|   let extendPaths; | ||||
|   ({extends: extendPaths, ...options} = options); | ||||
|  | ||||
| @ -163,18 +163,6 @@ test.serial('Do not set properties in option for which arg is not in command lin | ||||
|   t.false('e' in run.args[0][0]); | ||||
| }); | ||||
| 
 | ||||
| test.serial('Set "noCi" options to "true" with "--no-ci"', async t => { | ||||
|   const run = stub().resolves(true); | ||||
|   const argv = ['', '', '--no-ci']; | ||||
|   const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}}); | ||||
| 
 | ||||
|   const exitCode = await cli(); | ||||
| 
 | ||||
|   t.is(run.args[0][0].noCi, true); | ||||
| 
 | ||||
|   t.is(exitCode, 0); | ||||
| }); | ||||
| 
 | ||||
| test.serial('Display help', async t => { | ||||
|   const run = stub().resolves(true); | ||||
|   const argv = ['', '', '--help']; | ||||
|  | ||||
| @ -67,6 +67,18 @@ test('Default values, reading repositoryUrl (http url) from package.json if not | ||||
|   t.is(result.tagFormat, `v\${version}`); | ||||
| }); | ||||
| 
 | ||||
| test('Convert "ci" option to "noCi"', async t => { | ||||
|   const pkg = {repository: 'https://host.null/owner/module.git', release: {ci: false}}; | ||||
|   // Create a git repository, set the current working directory at the root of the repo
 | ||||
|   const {cwd} = await gitRepo(); | ||||
|   // Create package.json in repository root
 | ||||
|   await outputJson(path.resolve(cwd, 'package.json'), pkg); | ||||
| 
 | ||||
|   const {options: result} = await t.context.getConfig({cwd}); | ||||
| 
 | ||||
|   t.is(result.noCi, true); | ||||
| }); | ||||
| 
 | ||||
| test('Read options from package.json', async t => { | ||||
|   // Create a git repository, set the current working directory at the root of the repo
 | ||||
|   const {cwd} = await gitRepo(); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user