fix: revert to execa ^1.0.0
				
					
				
			This commit is contained in:
		
							parent
							
								
									228fed7a0b
								
							
						
					
					
						commit
						6b3adf6bbe
					
				| @ -45,7 +45,7 @@ async function isRefInHistory(ref, execaOpts) { | ||||
|     await execa('git', ['merge-base', '--is-ancestor', ref, 'HEAD'], execaOpts); | ||||
|     return true; | ||||
|   } catch (error) { | ||||
|     if (error.exitCode === 1) { | ||||
|     if (error.code === 1) { | ||||
|       return false; | ||||
|     } | ||||
| 
 | ||||
| @ -103,7 +103,7 @@ async function repoUrl(execaOpts) { | ||||
|  */ | ||||
| async function isGitRepo(execaOpts) { | ||||
|   try { | ||||
|     return (await execa('git', ['rev-parse', '--git-dir'], execaOpts)).exitCode === 0; | ||||
|     return (await execa('git', ['rev-parse', '--git-dir'], execaOpts)).code === 0; | ||||
|   } catch (error) { | ||||
|     debug(error); | ||||
|   } | ||||
| @ -161,7 +161,7 @@ async function push(repositoryUrl, execaOpts) { | ||||
|  */ | ||||
| async function verifyTagName(tagName, execaOpts) { | ||||
|   try { | ||||
|     return (await execa('git', ['check-ref-format', `refs/tags/${tagName}`], execaOpts)).exitCode === 0; | ||||
|     return (await execa('git', ['check-ref-format', `refs/tags/${tagName}`], execaOpts)).code === 0; | ||||
|   } catch (error) { | ||||
|     debug(error); | ||||
|   } | ||||
|  | ||||
| @ -36,7 +36,7 @@ | ||||
|     "cosmiconfig": "^5.0.1", | ||||
|     "debug": "^4.0.0", | ||||
|     "env-ci": "^4.0.0", | ||||
|     "execa": "^2.0.0", | ||||
|     "execa": "^1.0.0", | ||||
|     "figures": "^3.0.0", | ||||
|     "find-versions": "^3.0.0", | ||||
|     "get-stream": "^5.0.0", | ||||
|  | ||||
| @ -66,7 +66,7 @@ test.serial('Pass options to semantic-release API', async t => { | ||||
|   ]; | ||||
|   const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}}); | ||||
| 
 | ||||
|   const exitCode = await cli(); | ||||
|   const code = await cli(); | ||||
| 
 | ||||
|   t.is(run.args[0][0].branch, 'master'); | ||||
|   t.is(run.args[0][0].repositoryUrl, 'https://github/com/owner/repo.git'); | ||||
| @ -84,7 +84,7 @@ test.serial('Pass options to semantic-release API', async t => { | ||||
|   t.is(run.args[0][0].debug, true); | ||||
|   t.is(run.args[0][0].dryRun, true); | ||||
| 
 | ||||
|   t.is(exitCode, 0); | ||||
|   t.is(code, 0); | ||||
| }); | ||||
| 
 | ||||
| test.serial('Pass options to semantic-release API with alias arguments', async t => { | ||||
| @ -108,7 +108,7 @@ test.serial('Pass options to semantic-release API with alias arguments', async t | ||||
|   ]; | ||||
|   const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}}); | ||||
| 
 | ||||
|   const exitCode = await cli(); | ||||
|   const code = await cli(); | ||||
| 
 | ||||
|   t.is(run.args[0][0].branch, 'master'); | ||||
|   t.is(run.args[0][0].repositoryUrl, 'https://github/com/owner/repo.git'); | ||||
| @ -117,7 +117,7 @@ test.serial('Pass options to semantic-release API with alias arguments', async t | ||||
|   t.deepEqual(run.args[0][0].extends, ['config1', 'config2']); | ||||
|   t.is(run.args[0][0].dryRun, true); | ||||
| 
 | ||||
|   t.is(exitCode, 0); | ||||
|   t.is(code, 0); | ||||
| }); | ||||
| 
 | ||||
| test.serial('Pass unknown options to semantic-release API', async t => { | ||||
| @ -125,13 +125,13 @@ test.serial('Pass unknown options to semantic-release API', async t => { | ||||
|   const argv = ['', '', '--bool', '--first-option', 'value1', '--second-option', 'value2', '--second-option', 'value3']; | ||||
|   const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}}); | ||||
| 
 | ||||
|   const exitCode = await cli(); | ||||
|   const code = await cli(); | ||||
| 
 | ||||
|   t.is(run.args[0][0].bool, true); | ||||
|   t.is(run.args[0][0].firstOption, 'value1'); | ||||
|   t.deepEqual(run.args[0][0].secondOption, ['value2', 'value3']); | ||||
| 
 | ||||
|   t.is(exitCode, 0); | ||||
|   t.is(code, 0); | ||||
| }); | ||||
| 
 | ||||
| test.serial('Pass empty Array to semantic-release API for list option set to "false"', async t => { | ||||
| @ -139,11 +139,11 @@ test.serial('Pass empty Array to semantic-release API for list option set to "fa | ||||
|   const argv = ['', '', '--publish', 'false']; | ||||
|   const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}}); | ||||
| 
 | ||||
|   const exitCode = await cli(); | ||||
|   const code = await cli(); | ||||
| 
 | ||||
|   t.deepEqual(run.args[0][0].publish, []); | ||||
| 
 | ||||
|   t.is(exitCode, 0); | ||||
|   t.is(code, 0); | ||||
| }); | ||||
| 
 | ||||
| test.serial('Do not set properties in option for which arg is not in command line', async t => { | ||||
| @ -168,10 +168,10 @@ test.serial('Display help', async t => { | ||||
|   const argv = ['', '', '--help']; | ||||
|   const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}}); | ||||
| 
 | ||||
|   const exitCode = await cli(); | ||||
|   const code = await cli(); | ||||
| 
 | ||||
|   t.regex(t.context.logs, /Run automated package publishing/); | ||||
|   t.is(exitCode, 0); | ||||
|   t.is(code, 0); | ||||
| }); | ||||
| 
 | ||||
| test.serial('Return error code and prints help if called with a command', async t => { | ||||
| @ -179,11 +179,11 @@ test.serial('Return error code and prints help if called with a command', async | ||||
|   const argv = ['', '', 'pre']; | ||||
|   const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}}); | ||||
| 
 | ||||
|   const exitCode = await cli(); | ||||
|   const code = await cli(); | ||||
| 
 | ||||
|   t.regex(t.context.errors, /Run automated package publishing/); | ||||
|   t.regex(t.context.errors, /Too many non-option arguments/); | ||||
|   t.is(exitCode, 1); | ||||
|   t.is(code, 1); | ||||
| }); | ||||
| 
 | ||||
| test.serial('Return error code if multiple plugin are set for single plugin', async t => { | ||||
| @ -191,11 +191,11 @@ test.serial('Return error code if multiple plugin are set for single plugin', as | ||||
|   const argv = ['', '', '--analyze-commits', 'analyze1', 'analyze2']; | ||||
|   const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}}); | ||||
| 
 | ||||
|   const exitCode = await cli(); | ||||
|   const code = await cli(); | ||||
| 
 | ||||
|   t.regex(t.context.errors, /Run automated package publishing/); | ||||
|   t.regex(t.context.errors, /Too many non-option arguments/); | ||||
|   t.is(exitCode, 1); | ||||
|   t.is(code, 1); | ||||
| }); | ||||
| 
 | ||||
| test.serial('Return error code if semantic-release throw error', async t => { | ||||
| @ -203,10 +203,10 @@ test.serial('Return error code if semantic-release throw error', async t => { | ||||
|   const argv = ['', '']; | ||||
|   const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}}); | ||||
| 
 | ||||
|   const exitCode = await cli(); | ||||
|   const code = await cli(); | ||||
| 
 | ||||
|   t.regex(t.context.errors, /semantic-release error/); | ||||
|   t.is(exitCode, 1); | ||||
|   t.is(code, 1); | ||||
| }); | ||||
| 
 | ||||
| test.serial('Hide sensitive environment variable values from the logs', async t => { | ||||
| @ -215,8 +215,8 @@ test.serial('Hide sensitive environment variable values from the logs', async t | ||||
|   const argv = ['', '']; | ||||
|   const cli = requireNoCache('../cli', {'.': run, process: {...process, argv, env: {...process.env, ...env}}}); | ||||
| 
 | ||||
|   const exitCode = await cli(); | ||||
|   const code = await cli(); | ||||
| 
 | ||||
|   t.regex(t.context.errors, new RegExp(`Throw error: Exposing token ${escapeRegExp(SECRET_REPLACEMENT)}`)); | ||||
|   t.is(exitCode, 1); | ||||
|   t.is(code, 1); | ||||
| }); | ||||
|  | ||||
| @ -72,9 +72,9 @@ test('Release patch, minor and major versions', async t => { | ||||
|   t.log('Commit a chore'); | ||||
|   await gitCommits(['chore: Init repository'], {cwd}); | ||||
|   t.log('$ semantic-release'); | ||||
|   let {stdout, exitCode} = await execa(cli, [], {env, cwd}); | ||||
|   let {stdout, code} = await execa(cli, [], {env, cwd}); | ||||
|   t.regex(stdout, /There are no relevant changes, so no new version is released/); | ||||
|   t.is(exitCode, 0); | ||||
|   t.is(code, 0); | ||||
| 
 | ||||
|   /* Initial release */ | ||||
|   let version = '1.0.0'; | ||||
| @ -95,10 +95,10 @@ test('Release patch, minor and major versions', async t => { | ||||
|   t.log('Commit a feature'); | ||||
|   await gitCommits(['feat: Initial commit'], {cwd}); | ||||
|   t.log('$ semantic-release'); | ||||
|   ({stdout, exitCode} = await execa(cli, [], {env, cwd})); | ||||
|   ({stdout, code} = await execa(cli, [], {env, cwd})); | ||||
|   t.regex(stdout, new RegExp(`Published GitHub release: release-url/${version}`)); | ||||
|   t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`)); | ||||
|   t.is(exitCode, 0); | ||||
|   t.is(code, 0); | ||||
| 
 | ||||
|   // Verify package.json and npm-shrinkwrap.json have been updated
 | ||||
|   t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version); | ||||
| @ -137,10 +137,10 @@ test('Release patch, minor and major versions', async t => { | ||||
|   t.log('Commit a fix'); | ||||
|   await gitCommits(['fix: bar'], {cwd}); | ||||
|   t.log('$ semantic-release'); | ||||
|   ({stdout, exitCode} = await execa(cli, [], {env, cwd})); | ||||
|   ({stdout, code} = await execa(cli, [], {env, cwd})); | ||||
|   t.regex(stdout, new RegExp(`Published GitHub release: release-url/${version}`)); | ||||
|   t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`)); | ||||
|   t.is(exitCode, 0); | ||||
|   t.is(code, 0); | ||||
| 
 | ||||
|   // Verify package.json and npm-shrinkwrap.json have been updated
 | ||||
|   t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version); | ||||
| @ -179,10 +179,10 @@ test('Release patch, minor and major versions', async t => { | ||||
|   t.log('Commit a feature'); | ||||
|   await gitCommits(['feat: baz'], {cwd}); | ||||
|   t.log('$ semantic-release'); | ||||
|   ({stdout, exitCode} = await execa(cli, [], {env, cwd})); | ||||
|   ({stdout, code} = await execa(cli, [], {env, cwd})); | ||||
|   t.regex(stdout, new RegExp(`Published GitHub release: release-url/${version}`)); | ||||
|   t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`)); | ||||
|   t.is(exitCode, 0); | ||||
|   t.is(code, 0); | ||||
| 
 | ||||
|   // Verify package.json and npm-shrinkwrap.json have been updated
 | ||||
|   t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version); | ||||
| @ -221,10 +221,10 @@ test('Release patch, minor and major versions', async t => { | ||||
|   t.log('Commit a breaking change'); | ||||
|   await gitCommits(['feat: foo\n\n BREAKING CHANGE: bar'], {cwd}); | ||||
|   t.log('$ semantic-release'); | ||||
|   ({stdout, exitCode} = await execa(cli, [], {env, cwd})); | ||||
|   ({stdout, code} = await execa(cli, [], {env, cwd})); | ||||
|   t.regex(stdout, new RegExp(`Published GitHub release: release-url/${version}`)); | ||||
|   t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`)); | ||||
|   t.is(exitCode, 0); | ||||
|   t.is(code, 0); | ||||
| 
 | ||||
|   // Verify package.json and npm-shrinkwrap.json have been updated
 | ||||
|   t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version); | ||||
| @ -258,8 +258,8 @@ test('Exit with 1 if a plugin is not found', async t => { | ||||
|     release: {analyzeCommits: 'non-existing-path', success: false, fail: false}, | ||||
|   }); | ||||
| 
 | ||||
|   const {exitCode, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd})); | ||||
|   t.is(exitCode, 1); | ||||
|   const {code, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd})); | ||||
|   t.is(code, 1); | ||||
|   t.regex(stderr, /Cannot find module/); | ||||
| }); | ||||
| 
 | ||||
| @ -276,8 +276,8 @@ test('Exit with 1 if a shareable config is not found', async t => { | ||||
|     release: {extends: 'non-existing-path', success: false, fail: false}, | ||||
|   }); | ||||
| 
 | ||||
|   const {exitCode, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd})); | ||||
|   t.is(exitCode, 1); | ||||
|   const {code, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd})); | ||||
|   t.is(code, 1); | ||||
|   t.regex(stderr, /Cannot find module/); | ||||
| }); | ||||
| 
 | ||||
| @ -297,8 +297,8 @@ test('Exit with 1 if a shareable config reference a not found plugin', async t = | ||||
|   }); | ||||
|   await writeJson(path.resolve(cwd, 'shareable.json'), shareable); | ||||
| 
 | ||||
|   const {exitCode, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd})); | ||||
|   t.is(exitCode, 1); | ||||
|   const {code, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd})); | ||||
|   t.is(code, 1); | ||||
|   t.regex(stderr, /Cannot find module/); | ||||
| }); | ||||
| 
 | ||||
| @ -327,11 +327,11 @@ test('Dry-run', async t => { | ||||
|   t.log('Commit a feature'); | ||||
|   await gitCommits(['feat: Initial commit'], {cwd}); | ||||
|   t.log('$ semantic-release -d'); | ||||
|   const {stdout, exitCode} = await execa(cli, ['-d'], {env, cwd}); | ||||
|   const {stdout, code} = await execa(cli, ['-d'], {env, cwd}); | ||||
|   t.regex(stdout, new RegExp(`There is no previous release, the next release version is ${version}`)); | ||||
|   t.regex(stdout, new RegExp(`Release note for version ${version}`)); | ||||
|   t.regex(stdout, /Initial commit/); | ||||
|   t.is(exitCode, 0); | ||||
|   t.is(code, 0); | ||||
| 
 | ||||
|   // Verify package.json and has not been modified
 | ||||
|   t.is((await readJson(path.resolve(cwd, 'package.json'))).version, '0.0.0-dev'); | ||||
| @ -375,10 +375,10 @@ test('Allow local releases with "noCi" option', async t => { | ||||
|   t.log('Commit a feature'); | ||||
|   await gitCommits(['feat: Initial commit'], {cwd}); | ||||
|   t.log('$ semantic-release --no-ci'); | ||||
|   const {stdout, exitCode} = await execa(cli, ['--no-ci'], {env: envNoCi, cwd}); | ||||
|   const {stdout, code} = await execa(cli, ['--no-ci'], {env: envNoCi, cwd}); | ||||
|   t.regex(stdout, new RegExp(`Published GitHub release: release-url/${version}`)); | ||||
|   t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`)); | ||||
|   t.is(exitCode, 0); | ||||
|   t.is(code, 0); | ||||
| 
 | ||||
|   // Verify package.json and has been updated
 | ||||
|   t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version); | ||||
| @ -417,7 +417,7 @@ test('Pass options via CLI arguments', async t => { | ||||
|   t.log('Commit a feature'); | ||||
|   await gitCommits(['feat: Initial commit'], {cwd}); | ||||
|   t.log('$ semantic-release'); | ||||
|   const {stdout, exitCode} = await execa( | ||||
|   const {stdout, code} = await execa( | ||||
|     cli, | ||||
|     [ | ||||
|       '--verify-conditions', | ||||
| @ -433,7 +433,7 @@ test('Pass options via CLI arguments', async t => { | ||||
|     {env, cwd} | ||||
|   ); | ||||
|   t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`)); | ||||
|   t.is(exitCode, 0); | ||||
|   t.is(code, 0); | ||||
| 
 | ||||
|   // Verify package.json and has been updated
 | ||||
|   t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version); | ||||
| @ -528,14 +528,14 @@ test('Log unexpected errors from plugins and exit with 1', async t => { | ||||
|   t.log('Commit a feature'); | ||||
|   await gitCommits(['feat: Initial commit'], {cwd}); | ||||
|   t.log('$ semantic-release'); | ||||
|   const {stderr, exitCode} = await execa(cli, [], {env, cwd, reject: false}); | ||||
|   const {stderr, code} = await execa(cli, [], {env, cwd, reject: false}); | ||||
|   // Verify the type and message are logged
 | ||||
|   t.regex(stderr, /Error: a/); | ||||
|   // Verify the the stacktrace is logged
 | ||||
|   t.regex(stderr, new RegExp(pluginError)); | ||||
|   // Verify the Error properties are logged
 | ||||
|   t.regex(stderr, /errorProperty: 'errorProperty'/); | ||||
|   t.is(exitCode, 1); | ||||
|   t.is(code, 1); | ||||
| }); | ||||
| 
 | ||||
| test('Log errors inheriting SemanticReleaseError and exit with 1', async t => { | ||||
| @ -555,10 +555,10 @@ test('Log errors inheriting SemanticReleaseError and exit with 1', async t => { | ||||
|   t.log('Commit a feature'); | ||||
|   await gitCommits(['feat: Initial commit'], {cwd}); | ||||
|   t.log('$ semantic-release'); | ||||
|   const {stderr, exitCode} = await execa(cli, [], {env, cwd, reject: false}); | ||||
|   const {stderr, code} = await execa(cli, [], {env, cwd, reject: false}); | ||||
|   // Verify the type and message are logged
 | ||||
|   t.regex(stderr, /EINHERITED Inherited error/); | ||||
|   t.is(exitCode, 1); | ||||
|   t.is(code, 1); | ||||
| }); | ||||
| 
 | ||||
| test('Exit with 1 if missing permission to push to the remote repository', async t => { | ||||
| @ -573,14 +573,14 @@ test('Exit with 1 if missing permission to push to the remote repository', async | ||||
|   await gitCommits(['feat: Initial commit'], {cwd}); | ||||
|   await gitPush('origin', 'master', {cwd}); | ||||
|   t.log('$ semantic-release'); | ||||
|   const {stderr, exitCode} = await execa( | ||||
|   const {stderr, code} = await execa( | ||||
|     cli, | ||||
|     ['--repository-url', 'http://user:wrong_pass@localhost:2080/git/unauthorized.git'], | ||||
|     {env: {...env, GH_TOKEN: 'user:wrong_pass'}, cwd, reject: false} | ||||
|   ); | ||||
|   // Verify the type and message are logged
 | ||||
|   t.regex(stderr, /EGITNOPERMISSION/); | ||||
|   t.is(exitCode, 1); | ||||
|   t.is(code, 1); | ||||
| }); | ||||
| 
 | ||||
| test('Hide sensitive environment variable values from the logs', async t => { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user