WIP esm - adapt sinon
This commit is contained in:
		
							parent
							
								
									ce263c5f4a
								
							
						
					
					
						commit
						ab7a428102
					
				| @ -1,16 +1,16 @@ | |||||||
| import test from 'ava'; | import test from 'ava'; | ||||||
| import {escapeRegExp} from 'lodash'; | import {escapeRegExp} from 'lodash'; | ||||||
| const proxyquire = require('proxyquire').noPreserveCache(); | const proxyquire = require('proxyquire').noPreserveCache(); | ||||||
| import {stub} from 'sinon'; | import sinon from 'sinon'; | ||||||
| import {SECRET_REPLACEMENT} from '../lib/definitions/constants.js'; | import {SECRET_REPLACEMENT} from '../lib/definitions/constants.js'; | ||||||
| 
 | 
 | ||||||
| test.beforeEach((t) => { | test.beforeEach((t) => { | ||||||
|   t.context.logs = ''; |   t.context.logs = ''; | ||||||
|   t.context.errors = ''; |   t.context.errors = ''; | ||||||
|   t.context.stdout = stub(process.stdout, 'write').callsFake((value) => { |   t.context.stdout = sinon.stubprocess.stdout, 'write').callsFake((value) => { | ||||||
|     t.context.logs += value.toString(); |     t.context.logs += value.toString(); | ||||||
|   }); |   }); | ||||||
|   t.context.stderr = stub(process.stderr, 'write').callsFake((value) => { |   t.context.stderr = sinon.stubprocess.stderr, 'write').callsFake((value) => { | ||||||
|     t.context.errors += value.toString(); |     t.context.errors += value.toString(); | ||||||
|   }); |   }); | ||||||
| }); | }); | ||||||
| @ -21,7 +21,7 @@ test.afterEach.always((t) => { | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test.serial('Pass options to semantic-release API', async (t) => { | test.serial('Pass options to semantic-release API', async (t) => { | ||||||
|   const run = stub().resolves(true); |   const run = sinon.stub).resolves(true); | ||||||
|   const argv = [ |   const argv = [ | ||||||
|     '', |     '', | ||||||
|     '', |     '', | ||||||
| @ -87,7 +87,7 @@ test.serial('Pass options to semantic-release API', async (t) => { | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test.serial('Pass options to semantic-release API with alias arguments', async (t) => { | test.serial('Pass options to semantic-release API with alias arguments', async (t) => { | ||||||
|   const run = stub().resolves(true); |   const run = sinon.stub).resolves(true); | ||||||
|   const argv = [ |   const argv = [ | ||||||
|     '', |     '', | ||||||
|     '', |     '', | ||||||
| @ -120,7 +120,7 @@ test.serial('Pass options to semantic-release API with alias arguments', async ( | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test.serial('Pass unknown options to semantic-release API', async (t) => { | test.serial('Pass unknown options to semantic-release API', async (t) => { | ||||||
|   const run = stub().resolves(true); |   const run = sinon.stub).resolves(true); | ||||||
|   const argv = ['', '', '--bool', '--first-option', 'value1', '--second-option', 'value2', '--second-option', 'value3']; |   const argv = ['', '', '--bool', '--first-option', 'value1', '--second-option', 'value2', '--second-option', 'value3']; | ||||||
|   const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); |   const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); | ||||||
| 
 | 
 | ||||||
| @ -134,7 +134,7 @@ test.serial('Pass unknown options to semantic-release API', async (t) => { | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test.serial('Pass empty Array to semantic-release API for list option set to "false"', async (t) => { | test.serial('Pass empty Array to semantic-release API for list option set to "false"', async (t) => { | ||||||
|   const run = stub().resolves(true); |   const run = sinon.stub).resolves(true); | ||||||
|   const argv = ['', '', '--publish', 'false']; |   const argv = ['', '', '--publish', 'false']; | ||||||
|   const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); |   const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); | ||||||
| 
 | 
 | ||||||
| @ -146,7 +146,7 @@ test.serial('Pass empty Array to semantic-release API for list option set to "fa | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test.serial('Do not set properties in option for which arg is not in command line', async (t) => { | test.serial('Do not set properties in option for which arg is not in command line', async (t) => { | ||||||
|   const run = stub().resolves(true); |   const run = sinon.stub).resolves(true); | ||||||
|   const argv = ['', '', '-b', 'master']; |   const argv = ['', '', '-b', 'master']; | ||||||
|   const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); |   const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); | ||||||
| 
 | 
 | ||||||
| @ -163,7 +163,7 @@ test.serial('Do not set properties in option for which arg is not in command lin | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test.serial('Display help', async (t) => { | test.serial('Display help', async (t) => { | ||||||
|   const run = stub().resolves(true); |   const run = sinon.stub).resolves(true); | ||||||
|   const argv = ['', '', '--help']; |   const argv = ['', '', '--help']; | ||||||
|   const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); |   const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); | ||||||
| 
 | 
 | ||||||
| @ -174,7 +174,7 @@ test.serial('Display help', async (t) => { | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test.serial('Return error exitCode and prints help if called with a command', async (t) => { | test.serial('Return error exitCode and prints help if called with a command', async (t) => { | ||||||
|   const run = stub().resolves(true); |   const run = sinon.stub).resolves(true); | ||||||
|   const argv = ['', '', 'pre']; |   const argv = ['', '', 'pre']; | ||||||
|   const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); |   const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); | ||||||
| 
 | 
 | ||||||
| @ -186,7 +186,7 @@ test.serial('Return error exitCode and prints help if called with a command', as | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test.serial('Return error exitCode if multiple plugin are set for single plugin', async (t) => { | test.serial('Return error exitCode if multiple plugin are set for single plugin', async (t) => { | ||||||
|   const run = stub().resolves(true); |   const run = sinon.stub).resolves(true); | ||||||
|   const argv = ['', '', '--analyze-commits', 'analyze1', 'analyze2']; |   const argv = ['', '', '--analyze-commits', 'analyze1', 'analyze2']; | ||||||
|   const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); |   const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); | ||||||
| 
 | 
 | ||||||
| @ -198,7 +198,7 @@ test.serial('Return error exitCode if multiple plugin are set for single plugin' | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test.serial('Return error exitCode if semantic-release throw error', async (t) => { | test.serial('Return error exitCode if semantic-release throw error', async (t) => { | ||||||
|   const run = stub().rejects(new Error('semantic-release error')); |   const run = sinon.stub).rejects(new Error('semantic-release error')); | ||||||
|   const argv = ['', '']; |   const argv = ['', '']; | ||||||
|   const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); |   const cli = proxyquire('../cli', {'.': run, process: {...process, argv}}); | ||||||
| 
 | 
 | ||||||
| @ -210,7 +210,7 @@ test.serial('Return error exitCode if semantic-release throw error', async (t) = | |||||||
| 
 | 
 | ||||||
| test.serial('Hide sensitive environment variable values from the logs', async (t) => { | test.serial('Hide sensitive environment variable values from the logs', async (t) => { | ||||||
|   const env = {MY_TOKEN: 'secret token'}; |   const env = {MY_TOKEN: 'secret token'}; | ||||||
|   const run = stub().rejects(new Error(`Throw error: Exposing token ${env.MY_TOKEN}`)); |   const run = sinon.stub).rejects(new Error(`Throw error: Exposing token ${env.MY_TOKEN}`)); | ||||||
|   const argv = ['', '']; |   const argv = ['', '']; | ||||||
|   const cli = proxyquire('../cli', {'.': run, process: {...process, argv, env: {...process.env, ...env}}}); |   const cli = proxyquire('../cli', {'.': run, process: {...process, argv, env: {...process.env, ...env}}}); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,12 +1,12 @@ | |||||||
| import test from 'ava'; | import test from 'ava'; | ||||||
| import {stub} from 'sinon'; | import sinon from 'sinon'; | ||||||
| import getCommits from '../lib/get-commits.js'; | import getCommits from '../lib/get-commits.js'; | ||||||
| import {gitRepo, gitCommits, gitDetachedHead} from './helpers/git-utils.js'; | import {gitRepo, gitCommits, gitDetachedHead} from './helpers/git-utils.js'; | ||||||
| 
 | 
 | ||||||
| test.beforeEach((t) => { | test.beforeEach((t) => { | ||||||
|   // Stub the logger functions
 |   // Stub the logger functions
 | ||||||
|   t.context.log = stub(); |   t.context.log = sinon.stub(); | ||||||
|   t.context.error = stub(); |   t.context.error = sinon.stub(); | ||||||
|   t.context.logger = {log: t.context.log, error: t.context.error}; |   t.context.logger = {log: t.context.log, error: t.context.error}; | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ import test from 'ava'; | |||||||
| import {writeFile, outputJson} from 'fs-extra'; | import {writeFile, outputJson} from 'fs-extra'; | ||||||
| import {omit} from 'lodash'; | import {omit} from 'lodash'; | ||||||
| import proxyquire from 'proxyquire'; | import proxyquire from 'proxyquire'; | ||||||
| import {stub} from 'sinon'; | import sinon from 'sinon'; | ||||||
| import yaml from 'js-yaml'; | import yaml from 'js-yaml'; | ||||||
| import {gitRepo, gitTagVersion, gitCommits, gitShallowClone, gitAddConfig} from './helpers/git-utils.js'; | import {gitRepo, gitTagVersion, gitCommits, gitShallowClone, gitAddConfig} from './helpers/git-utils.js'; | ||||||
| 
 | 
 | ||||||
| @ -16,7 +16,7 @@ const DEFAULT_PLUGINS = [ | |||||||
| ]; | ]; | ||||||
| 
 | 
 | ||||||
| test.beforeEach((t) => { | test.beforeEach((t) => { | ||||||
|   t.context.plugins = stub().returns({}); |   t.context.plugins = sinon.stub).returns({}); | ||||||
|   t.context.getConfig = proxyquire('../lib/get-config', {'./plugins': t.context.plugins}); |   t.context.getConfig = proxyquire('../lib/get-config', {'./plugins': t.context.plugins}); | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,10 +1,10 @@ | |||||||
| import test from 'ava'; | import test from 'ava'; | ||||||
| import {stub} from 'sinon'; | import sinon from 'sinon'; | ||||||
| import getNextVersion from '../lib/get-next-version.js'; | import getNextVersion from '../lib/get-next-version.js'; | ||||||
| 
 | 
 | ||||||
| test.beforeEach((t) => { | test.beforeEach((t) => { | ||||||
|   // Stub the logger functions
 |   // Stub the logger functions
 | ||||||
|   t.context.log = stub(); |   t.context.log = sinon.stub); | ||||||
|   t.context.logger = {log: t.context.log}; |   t.context.logger = {log: t.context.log}; | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| import test from 'ava'; | import test from 'ava'; | ||||||
| import {escapeRegExp, isString, sortBy, omit} from 'lodash'; | import {escapeRegExp, isString, sortBy, omit} from 'lodash'; | ||||||
| import proxyquire from 'proxyquire'; | import proxyquire from 'proxyquire'; | ||||||
| import {spy, stub} from 'sinon'; | import sinon from 'sinon'; | ||||||
| import {WritableStreamBuffer} from 'stream-buffers'; | import {WritableStreamBuffer} from 'stream-buffers'; | ||||||
| import AggregateError from 'aggregate-error'; | import AggregateError from 'aggregate-error'; | ||||||
| import SemanticReleaseError from '@semantic-release/error'; | import SemanticReleaseError from '@semantic-release/error'; | ||||||
| @ -29,10 +29,10 @@ const pluginNoop = require.resolve('./fixtures/plugin-noop'); | |||||||
| 
 | 
 | ||||||
| test.beforeEach((t) => { | test.beforeEach((t) => { | ||||||
|   // Stub the logger functions
 |   // Stub the logger functions
 | ||||||
|   t.context.log = spy(); |   t.context.log = sinon.spy(); | ||||||
|   t.context.error = spy(); |   t.context.error = sinon.spy(); | ||||||
|   t.context.success = spy(); |   t.context.success = sinon.spy(); | ||||||
|   t.context.warn = spy(); |   t.context.warn = sinon.spy(); | ||||||
|   t.context.logger = { |   t.context.logger = { | ||||||
|     log: t.context.log, |     log: t.context.log, | ||||||
|     error: t.context.error, |     error: t.context.error, | ||||||
| @ -74,19 +74,19 @@ test('Plugins are called with expected values', async (t) => { | |||||||
|   const notes1 = 'Release notes 1'; |   const notes1 = 'Release notes 1'; | ||||||
|   const notes2 = 'Release notes 2'; |   const notes2 = 'Release notes 2'; | ||||||
|   const notes3 = 'Release notes 3'; |   const notes3 = 'Release notes 3'; | ||||||
|   const verifyConditions1 = stub().resolves(); |   const verifyConditions1 = sinon.stub().resolves(); | ||||||
|   const verifyConditions2 = stub().resolves(); |   const verifyConditions2 = sinon.stub().resolves(); | ||||||
|   const analyzeCommits = stub().resolves(nextRelease.type); |   const analyzeCommits = sinon.stub().resolves(nextRelease.type); | ||||||
|   const verifyRelease = stub().resolves(); |   const verifyRelease = sinon.stub().resolves(); | ||||||
|   const generateNotes1 = stub().resolves(notes1); |   const generateNotes1 = sinon.stub().resolves(notes1); | ||||||
|   const generateNotes2 = stub().resolves(notes2); |   const generateNotes2 = sinon.stub().resolves(notes2); | ||||||
|   const generateNotes3 = stub().resolves(notes3); |   const generateNotes3 = sinon.stub().resolves(notes3); | ||||||
|   const release1 = {name: 'Release 1', url: 'https://release1.com'}; |   const release1 = {name: 'Release 1', url: 'https://release1.com'}; | ||||||
|   const release2 = {name: 'Release 2', url: 'https://release2.com'}; |   const release2 = {name: 'Release 2', url: 'https://release2.com'}; | ||||||
|   const addChannel = stub().resolves(release1); |   const addChannel = sinon.stub().resolves(release1); | ||||||
|   const prepare = stub().resolves(); |   const prepare = sinon.stub().resolves(); | ||||||
|   const publish = stub().resolves(release2); |   const publish = sinon.stub().resolves(release2); | ||||||
|   const success = stub().resolves(); |   const success = sinon.stub().resolves(); | ||||||
|   const env = {}; |   const env = {}; | ||||||
|   const config = { |   const config = { | ||||||
|     branches: [{name: 'master'}, {name: 'next'}], |     branches: [{name: 'master'}, {name: 'next'}], | ||||||
| @ -409,15 +409,15 @@ test('Use custom tag format', async (t) => { | |||||||
|   const config = {branches: 'master', repositoryUrl, globalOpt: 'global', tagFormat: `test-\${version}`}; |   const config = {branches: 'master', repositoryUrl, globalOpt: 'global', tagFormat: `test-\${version}`}; | ||||||
|   const options = { |   const options = { | ||||||
|     ...config, |     ...config, | ||||||
|     verifyConditions: stub().resolves(), |     verifyConditions: sinon.stub().resolves(), | ||||||
|     analyzeCommits: stub().resolves(nextRelease.type), |     analyzeCommits: sinon.stub().resolves(nextRelease.type), | ||||||
|     verifyRelease: stub().resolves(), |     verifyRelease: sinon.stub().resolves(), | ||||||
|     generateNotes: stub().resolves(notes), |     generateNotes: sinon.stub().resolves(notes), | ||||||
|     addChannel: stub().resolves(), |     addChannel: sinon.stub().resolves(), | ||||||
|     prepare: stub().resolves(), |     prepare: sinon.stub().resolves(), | ||||||
|     publish: stub().resolves(), |     publish: sinon.stub().resolves(), | ||||||
|     success: stub().resolves(), |     success: sinon.stub().resolves(), | ||||||
|     fail: stub().resolves(), |     fail: sinon.stub().resolves(), | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const semanticRelease = requireNoCache('..', { |   const semanticRelease = requireNoCache('..', { | ||||||
| @ -459,24 +459,24 @@ test('Use new gitHead, and recreate release notes if a prepare plugin create a c | |||||||
|   }; |   }; | ||||||
|   const notes = 'Release notes'; |   const notes = 'Release notes'; | ||||||
| 
 | 
 | ||||||
|   const generateNotes = stub().resolves(notes); |   const generateNotes = sinon.stub().resolves(notes); | ||||||
|   const prepare1 = stub().callsFake(async () => { |   const prepare1 = sinon.stub().callsFake(async () => { | ||||||
|     commits = (await gitCommits(['Third'], {cwd})).concat(commits); |     commits = (await gitCommits(['Third'], {cwd})).concat(commits); | ||||||
|   }); |   }); | ||||||
|   const prepare2 = stub().resolves(); |   const prepare2 = sinon.stub().resolves(); | ||||||
|   const publish = stub().resolves(); |   const publish = sinon.stub().resolves(); | ||||||
|   const options = { |   const options = { | ||||||
|     branches: ['master'], |     branches: ['master'], | ||||||
|     repositoryUrl, |     repositoryUrl, | ||||||
|     verifyConditions: stub().resolves(), |     verifyConditions: sinon.stub().resolves(), | ||||||
|     analyzeCommits: stub().resolves(nextRelease.type), |     analyzeCommits: sinon.stub().resolves(nextRelease.type), | ||||||
|     verifyRelease: stub().resolves(), |     verifyRelease: sinon.stub().resolves(), | ||||||
|     generateNotes, |     generateNotes, | ||||||
|     addChannel: stub().resolves(), |     addChannel: sinon.stub().resolves(), | ||||||
|     prepare: [prepare1, prepare2], |     prepare: [prepare1, prepare2], | ||||||
|     publish, |     publish, | ||||||
|     success: stub().resolves(), |     success: sinon.stub().resolves(), | ||||||
|     fail: stub().resolves(), |     fail: sinon.stub().resolves(), | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const semanticRelease = requireNoCache('..', { |   const semanticRelease = requireNoCache('..', { | ||||||
| @ -528,12 +528,12 @@ test('Make a new release when a commit is forward-ported to an upper branch', as | |||||||
|   await merge('1.0.x', {cwd}); |   await merge('1.0.x', {cwd}); | ||||||
|   await gitPush('origin', 'master', {cwd}); |   await gitPush('origin', 'master', {cwd}); | ||||||
| 
 | 
 | ||||||
|   const verifyConditions = stub().resolves(); |   const verifyConditions = sinon.stub().resolves(); | ||||||
|   const verifyRelease = stub().resolves(); |   const verifyRelease = sinon.stub().resolves(); | ||||||
|   const addChannel = stub().resolves(); |   const addChannel = sinon.stub().resolves(); | ||||||
|   const prepare = stub().resolves(); |   const prepare = sinon.stub().resolves(); | ||||||
|   const publish = stub().resolves(); |   const publish = sinon.stub().resolves(); | ||||||
|   const success = stub().resolves(); |   const success = sinon.stub().resolves(); | ||||||
| 
 | 
 | ||||||
|   const config = {branches: [{name: '1.0.x'}, {name: 'master'}], repositoryUrl, tagFormat: `v\${version}`}; |   const config = {branches: [{name: '1.0.x'}, {name: 'master'}], repositoryUrl, tagFormat: `v\${version}`}; | ||||||
|   const options = { |   const options = { | ||||||
| @ -571,14 +571,14 @@ test('Publish a pre-release version', async (t) => { | |||||||
|   const config = {branches: ['master', {name: 'beta', prerelease: true}], repositoryUrl}; |   const config = {branches: ['master', {name: 'beta', prerelease: true}], repositoryUrl}; | ||||||
|   const options = { |   const options = { | ||||||
|     ...config, |     ...config, | ||||||
|     verifyConditions: stub().resolves(), |     verifyConditions: sinon.stub().resolves(), | ||||||
|     verifyRelease: stub().resolves(), |     verifyRelease: sinon.stub().resolves(), | ||||||
|     generateNotes: stub().resolves(''), |     generateNotes: sinon.stub().resolves(''), | ||||||
|     addChannel: false, |     addChannel: false, | ||||||
|     prepare: stub().resolves(), |     prepare: sinon.stub().resolves(), | ||||||
|     publish: stub().resolves(), |     publish: sinon.stub().resolves(), | ||||||
|     success: stub().resolves(), |     success: sinon.stub().resolves(), | ||||||
|     fail: stub().resolves(), |     fail: sinon.stub().resolves(), | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const semanticRelease = requireNoCache('..', { |   const semanticRelease = requireNoCache('..', { | ||||||
| @ -621,17 +621,17 @@ test('Publish releases from different branch on the same channel', async (t) => | |||||||
|     branches: ['master', {name: 'next', channel: false}, {name: 'next-major', channel: false}], |     branches: ['master', {name: 'next', channel: false}, {name: 'next-major', channel: false}], | ||||||
|     repositoryUrl, |     repositoryUrl, | ||||||
|   }; |   }; | ||||||
|   const addChannel = stub().resolves({}); |   const addChannel = sinon.stub().resolves({}); | ||||||
|   const options = { |   const options = { | ||||||
|     ...config, |     ...config, | ||||||
|     verifyConditions: stub().resolves(), |     verifyConditions: sinon.stub().resolves(), | ||||||
|     verifyRelease: stub().resolves(), |     verifyRelease: sinon.stub().resolves(), | ||||||
|     generateNotes: stub().resolves(''), |     generateNotes: sinon.stub().resolves(''), | ||||||
|     addChannel, |     addChannel, | ||||||
|     prepare: stub().resolves(), |     prepare: sinon.stub().resolves(), | ||||||
|     publish: stub().resolves(), |     publish: sinon.stub().resolves(), | ||||||
|     success: stub().resolves(), |     success: sinon.stub().resolves(), | ||||||
|     fail: stub().resolves(), |     fail: sinon.stub().resolves(), | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   let semanticRelease = requireNoCache('..', { |   let semanticRelease = requireNoCache('..', { | ||||||
| @ -684,14 +684,14 @@ test('Publish pre-releases the same channel as regular releases', async (t) => { | |||||||
|   }; |   }; | ||||||
|   const options = { |   const options = { | ||||||
|     ...config, |     ...config, | ||||||
|     verifyConditions: stub().resolves(), |     verifyConditions: sinon.stub().resolves(), | ||||||
|     verifyRelease: stub().resolves(), |     verifyRelease: sinon.stub().resolves(), | ||||||
|     generateNotes: stub().resolves(''), |     generateNotes: sinon.stub().resolves(''), | ||||||
|     addChannel: false, |     addChannel: false, | ||||||
|     prepare: stub().resolves(), |     prepare: sinon.stub().resolves(), | ||||||
|     publish: stub().resolves(), |     publish: sinon.stub().resolves(), | ||||||
|     success: stub().resolves(), |     success: sinon.stub().resolves(), | ||||||
|     fail: stub().resolves(), |     fail: sinon.stub().resolves(), | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const semanticRelease = requireNoCache('..', { |   const semanticRelease = requireNoCache('..', { | ||||||
| @ -734,14 +734,14 @@ test('Do not add pre-releases to a different channel', async (t) => { | |||||||
|   await merge('beta', {cwd}); |   await merge('beta', {cwd}); | ||||||
|   await gitPush('origin', 'master', {cwd}); |   await gitPush('origin', 'master', {cwd}); | ||||||
| 
 | 
 | ||||||
|   const verifyConditions = stub().resolves(); |   const verifyConditions = sinon.stub().resolves(); | ||||||
|   const verifyRelease = stub().resolves(); |   const verifyRelease = sinon.stub().resolves(); | ||||||
|   const generateNotes = stub().resolves('Release notes'); |   const generateNotes = sinon.stub().resolves('Release notes'); | ||||||
|   const release1 = {name: 'Release 1', url: 'https://release1.com'}; |   const release1 = {name: 'Release 1', url: 'https://release1.com'}; | ||||||
|   const addChannel = stub().resolves(release1); |   const addChannel = sinon.stub().resolves(release1); | ||||||
|   const prepare = stub().resolves(); |   const prepare = sinon.stub().resolves(); | ||||||
|   const publish = stub().resolves(); |   const publish = sinon.stub().resolves(); | ||||||
|   const success = stub().resolves(); |   const success = sinon.stub().resolves(); | ||||||
| 
 | 
 | ||||||
|   const config = { |   const config = { | ||||||
|     branches: [{name: 'master'}, {name: 'beta', prerelease: 'beta'}], |     branches: [{name: 'master'}, {name: 'beta', prerelease: 'beta'}], | ||||||
| @ -792,15 +792,15 @@ async function addChannelMacro(t, mergeFunction) { | |||||||
|   await gitPush('origin', 'master', {cwd}); |   await gitPush('origin', 'master', {cwd}); | ||||||
| 
 | 
 | ||||||
|   const notes = 'Release notes'; |   const notes = 'Release notes'; | ||||||
|   const verifyConditions = stub().resolves(); |   const verifyConditions = sinon.stub().resolves(); | ||||||
|   const verifyRelease = stub().resolves(); |   const verifyRelease = sinon.stub().resolves(); | ||||||
|   const generateNotes = stub().resolves(notes); |   const generateNotes = sinon.stub().resolves(notes); | ||||||
|   const release1 = {name: 'Release 1', url: 'https://release1.com'}; |   const release1 = {name: 'Release 1', url: 'https://release1.com'}; | ||||||
|   const addChannel1 = stub().resolves(release1); |   const addChannel1 = sinon.stub().resolves(release1); | ||||||
|   const addChannel2 = stub().resolves(); |   const addChannel2 = sinon.stub().resolves(); | ||||||
|   const prepare = stub().resolves(); |   const prepare = sinon.stub().resolves(); | ||||||
|   const publish = stub().resolves(); |   const publish = sinon.stub().resolves(); | ||||||
|   const success = stub().resolves(); |   const success = sinon.stub().resolves(); | ||||||
| 
 | 
 | ||||||
|   const config = { |   const config = { | ||||||
|     branches: [ |     branches: [ | ||||||
| @ -871,14 +871,14 @@ test('Call all "success" plugins even if one errors out', async (t) => { | |||||||
|     channel: null, |     channel: null, | ||||||
|   }; |   }; | ||||||
|   const notes = 'Release notes'; |   const notes = 'Release notes'; | ||||||
|   const verifyConditions1 = stub().resolves(); |   const verifyConditions1 = sinon.stub().resolves(); | ||||||
|   const verifyConditions2 = stub().resolves(); |   const verifyConditions2 = sinon.stub().resolves(); | ||||||
|   const analyzeCommits = stub().resolves(nextRelease.type); |   const analyzeCommits = sinon.stub().resolves(nextRelease.type); | ||||||
|   const generateNotes = stub().resolves(notes); |   const generateNotes = sinon.stub().resolves(notes); | ||||||
|   const release = {name: 'Release', url: 'https://release.com'}; |   const release = {name: 'Release', url: 'https://release.com'}; | ||||||
|   const publish = stub().resolves(release); |   const publish = sinon.stub().resolves(release); | ||||||
|   const success1 = stub().rejects(); |   const success1 = sinon.stub().rejects(); | ||||||
|   const success2 = stub().resolves(); |   const success2 = sinon.stub().resolves(); | ||||||
|   const config = { |   const config = { | ||||||
|     branches: [{name: 'master'}], |     branches: [{name: 'master'}], | ||||||
|     repositoryUrl, |     repositoryUrl, | ||||||
| @ -890,8 +890,8 @@ test('Call all "success" plugins even if one errors out', async (t) => { | |||||||
|     verifyConditions: [verifyConditions1, verifyConditions2], |     verifyConditions: [verifyConditions1, verifyConditions2], | ||||||
|     analyzeCommits, |     analyzeCommits, | ||||||
|     generateNotes, |     generateNotes, | ||||||
|     addChannel: stub().resolves(), |     addChannel: sinon.stub().resolves(), | ||||||
|     prepare: stub().resolves(), |     prepare: sinon.stub().resolves(), | ||||||
|     publish, |     publish, | ||||||
|     success: [success1, success2], |     success: [success1, success2], | ||||||
|   }; |   }; | ||||||
| @ -927,12 +927,12 @@ test('Log all "verifyConditions" errors', async (t) => { | |||||||
|   const error1 = new Error('error 1'); |   const error1 = new Error('error 1'); | ||||||
|   const error2 = new SemanticReleaseError('error 2', 'ERR2'); |   const error2 = new SemanticReleaseError('error 2', 'ERR2'); | ||||||
|   const error3 = new SemanticReleaseError('error 3', 'ERR3'); |   const error3 = new SemanticReleaseError('error 3', 'ERR3'); | ||||||
|   const fail = stub().resolves(); |   const fail = sinon.stub().resolves(); | ||||||
|   const config = {branches: [{name: 'master'}], repositoryUrl, tagFormat: `v\${version}`}; |   const config = {branches: [{name: 'master'}], repositoryUrl, tagFormat: `v\${version}`}; | ||||||
|   const options = { |   const options = { | ||||||
|     ...config, |     ...config, | ||||||
|     plugins: false, |     plugins: false, | ||||||
|     verifyConditions: [stub().rejects(new AggregateError([error1, error2])), stub().rejects(error3)], |     verifyConditions: [sinon.stub().rejects(new AggregateError([error1, error2])), sinon.stub().rejects(error3)], | ||||||
|     fail, |     fail, | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
| @ -971,13 +971,13 @@ test('Log all "verifyRelease" errors', async (t) => { | |||||||
| 
 | 
 | ||||||
|   const error1 = new SemanticReleaseError('error 1', 'ERR1'); |   const error1 = new SemanticReleaseError('error 1', 'ERR1'); | ||||||
|   const error2 = new SemanticReleaseError('error 2', 'ERR2'); |   const error2 = new SemanticReleaseError('error 2', 'ERR2'); | ||||||
|   const fail = stub().resolves(); |   const fail = sinon.stub().resolves(); | ||||||
|   const config = {branches: [{name: 'master'}], repositoryUrl, tagFormat: `v\${version}`}; |   const config = {branches: [{name: 'master'}], repositoryUrl, tagFormat: `v\${version}`}; | ||||||
|   const options = { |   const options = { | ||||||
|     ...config, |     ...config, | ||||||
|     verifyConditions: stub().resolves(), |     verifyConditions: sinon.stub().resolves(), | ||||||
|     analyzeCommits: stub().resolves('major'), |     analyzeCommits: sinon.stub().resolves('major'), | ||||||
|     verifyRelease: [stub().rejects(error1), stub().rejects(error2)], |     verifyRelease: [sinon.stub().rejects(error1), sinon.stub().rejects(error2)], | ||||||
|     fail, |     fail, | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
| @ -1012,14 +1012,14 @@ test('Dry-run skips addChannel, prepare, publish and success', async (t) => { | |||||||
|   await gitCheckout('next', true, {cwd}); |   await gitCheckout('next', true, {cwd}); | ||||||
|   await gitPush('origin', 'next', {cwd}); |   await gitPush('origin', 'next', {cwd}); | ||||||
| 
 | 
 | ||||||
|   const verifyConditions = stub().resolves(); |   const verifyConditions = sinon.stub().resolves(); | ||||||
|   const analyzeCommits = stub().resolves('minor'); |   const analyzeCommits = sinon.stub().resolves('minor'); | ||||||
|   const verifyRelease = stub().resolves(); |   const verifyRelease = sinon.stub().resolves(); | ||||||
|   const generateNotes = stub().resolves(); |   const generateNotes = sinon.stub().resolves(); | ||||||
|   const addChannel = stub().resolves(); |   const addChannel = sinon.stub().resolves(); | ||||||
|   const prepare = stub().resolves(); |   const prepare = sinon.stub().resolves(); | ||||||
|   const publish = stub().resolves(); |   const publish = sinon.stub().resolves(); | ||||||
|   const success = stub().resolves(); |   const success = sinon.stub().resolves(); | ||||||
| 
 | 
 | ||||||
|   const options = { |   const options = { | ||||||
|     dryRun: true, |     dryRun: true, | ||||||
| @ -1078,13 +1078,13 @@ test('Dry-run skips fail', async (t) => { | |||||||
| 
 | 
 | ||||||
|   const error1 = new SemanticReleaseError('error 1', 'ERR1'); |   const error1 = new SemanticReleaseError('error 1', 'ERR1'); | ||||||
|   const error2 = new SemanticReleaseError('error 2', 'ERR2'); |   const error2 = new SemanticReleaseError('error 2', 'ERR2'); | ||||||
|   const fail = stub().resolves(); |   const fail = sinon.stub().resolves(); | ||||||
| 
 | 
 | ||||||
|   const options = { |   const options = { | ||||||
|     dryRun: true, |     dryRun: true, | ||||||
|     branches: ['master'], |     branches: ['master'], | ||||||
|     repositoryUrl, |     repositoryUrl, | ||||||
|     verifyConditions: [stub().rejects(error1), stub().rejects(error2)], |     verifyConditions: [sinon.stub().rejects(error1), sinon.stub().rejects(error2)], | ||||||
|     fail, |     fail, | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
| @ -1126,12 +1126,12 @@ test('Force a dry-run if not on a CI and "noCi" is not explicitly set', async (t | |||||||
|   }; |   }; | ||||||
|   const notes = 'Release notes'; |   const notes = 'Release notes'; | ||||||
| 
 | 
 | ||||||
|   const verifyConditions = stub().resolves(); |   const verifyConditions = sinon.stub().resolves(); | ||||||
|   const analyzeCommits = stub().resolves(nextRelease.type); |   const analyzeCommits = sinon.stub().resolves(nextRelease.type); | ||||||
|   const verifyRelease = stub().resolves(); |   const verifyRelease = sinon.stub().resolves(); | ||||||
|   const generateNotes = stub().resolves(notes); |   const generateNotes = sinon.stub().resolves(notes); | ||||||
|   const publish = stub().resolves(); |   const publish = sinon.stub().resolves(); | ||||||
|   const success = stub().resolves(); |   const success = sinon.stub().resolves(); | ||||||
| 
 | 
 | ||||||
|   const options = { |   const options = { | ||||||
|     dryRun: false, |     dryRun: false, | ||||||
| @ -1141,11 +1141,11 @@ test('Force a dry-run if not on a CI and "noCi" is not explicitly set', async (t | |||||||
|     analyzeCommits, |     analyzeCommits, | ||||||
|     verifyRelease, |     verifyRelease, | ||||||
|     generateNotes, |     generateNotes, | ||||||
|     addChannel: stub().resolves(), |     addChannel: sinon.stub().resolves(), | ||||||
|     prepare: stub().resolves(), |     prepare: sinon.stub().resolves(), | ||||||
|     publish, |     publish, | ||||||
|     success, |     success, | ||||||
|     fail: stub().resolves(), |     fail: sinon.stub().resolves(), | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const semanticRelease = requireNoCache('..', { |   const semanticRelease = requireNoCache('..', { | ||||||
| @ -1182,8 +1182,8 @@ test('Dry-run does not print changelog if "generateNotes" return "undefined"', a | |||||||
|   await gitPush(repositoryUrl, 'master', {cwd}); |   await gitPush(repositoryUrl, 'master', {cwd}); | ||||||
| 
 | 
 | ||||||
|   const nextRelease = {type: 'major', version: '2.0.0', gitHead: await getGitHead({cwd}), gitTag: 'v2.0.0'}; |   const nextRelease = {type: 'major', version: '2.0.0', gitHead: await getGitHead({cwd}), gitTag: 'v2.0.0'}; | ||||||
|   const analyzeCommits = stub().resolves(nextRelease.type); |   const analyzeCommits = sinon.stub().resolves(nextRelease.type); | ||||||
|   const generateNotes = stub().resolves(); |   const generateNotes = sinon.stub().resolves(); | ||||||
| 
 | 
 | ||||||
|   const options = { |   const options = { | ||||||
|     dryRun: true, |     dryRun: true, | ||||||
| @ -1235,12 +1235,12 @@ test('Allow local releases with "noCi" option', async (t) => { | |||||||
|   }; |   }; | ||||||
|   const notes = 'Release notes'; |   const notes = 'Release notes'; | ||||||
| 
 | 
 | ||||||
|   const verifyConditions = stub().resolves(); |   const verifyConditions = sinon.stub().resolves(); | ||||||
|   const analyzeCommits = stub().resolves(nextRelease.type); |   const analyzeCommits = sinon.stub().resolves(nextRelease.type); | ||||||
|   const verifyRelease = stub().resolves(); |   const verifyRelease = sinon.stub().resolves(); | ||||||
|   const generateNotes = stub().resolves(notes); |   const generateNotes = sinon.stub().resolves(notes); | ||||||
|   const publish = stub().resolves(); |   const publish = sinon.stub().resolves(); | ||||||
|   const success = stub().resolves(); |   const success = sinon.stub().resolves(); | ||||||
| 
 | 
 | ||||||
|   const options = { |   const options = { | ||||||
|     noCi: true, |     noCi: true, | ||||||
| @ -1250,11 +1250,11 @@ test('Allow local releases with "noCi" option', async (t) => { | |||||||
|     analyzeCommits, |     analyzeCommits, | ||||||
|     verifyRelease, |     verifyRelease, | ||||||
|     generateNotes, |     generateNotes, | ||||||
|     addChannel: stub().resolves(), |     addChannel: sinon.stub().resolves(), | ||||||
|     prepare: stub().resolves(), |     prepare: sinon.stub().resolves(), | ||||||
|     publish, |     publish, | ||||||
|     success, |     success, | ||||||
|     fail: stub().resolves(), |     fail: sinon.stub().resolves(), | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const semanticRelease = requireNoCache('..', { |   const semanticRelease = requireNoCache('..', { | ||||||
| @ -1304,27 +1304,27 @@ test('Accept "undefined" value returned by "generateNotes" and "false" by "publi | |||||||
|     gitTag: 'v1.2.0', |     gitTag: 'v1.2.0', | ||||||
|     channel: null, |     channel: null, | ||||||
|   }; |   }; | ||||||
|   const analyzeCommits = stub().resolves(nextRelease.type); |   const analyzeCommits = sinon.stub().resolves(nextRelease.type); | ||||||
|   const verifyRelease = stub().resolves(); |   const verifyRelease = sinon.stub().resolves(); | ||||||
|   const generateNotes1 = stub().resolves(); |   const generateNotes1 = sinon.stub().resolves(); | ||||||
|   const notes2 = 'Release notes 2'; |   const notes2 = 'Release notes 2'; | ||||||
|   const generateNotes2 = stub().resolves(notes2); |   const generateNotes2 = sinon.stub().resolves(notes2); | ||||||
|   const publish = stub().resolves(false); |   const publish = sinon.stub().resolves(false); | ||||||
|   const addChannel = stub().resolves(false); |   const addChannel = sinon.stub().resolves(false); | ||||||
|   const success = stub().resolves(); |   const success = sinon.stub().resolves(); | ||||||
| 
 | 
 | ||||||
|   const options = { |   const options = { | ||||||
|     branches: ['master', 'next'], |     branches: ['master', 'next'], | ||||||
|     repositoryUrl, |     repositoryUrl, | ||||||
|     verifyConditions: stub().resolves(), |     verifyConditions: sinon.stub().resolves(), | ||||||
|     analyzeCommits, |     analyzeCommits, | ||||||
|     verifyRelease, |     verifyRelease, | ||||||
|     generateNotes: [generateNotes1, generateNotes2], |     generateNotes: [generateNotes1, generateNotes2], | ||||||
|     addChannel, |     addChannel, | ||||||
|     prepare: stub().resolves(), |     prepare: sinon.stub().resolves(), | ||||||
|     publish, |     publish, | ||||||
|     success, |     success, | ||||||
|     fail: stub().resolves(), |     fail: sinon.stub().resolves(), | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const semanticRelease = requireNoCache('..', { |   const semanticRelease = requireNoCache('..', { | ||||||
| @ -1387,12 +1387,12 @@ test('Throws "EINVALIDNEXTVERSION" if next release is out of range of the curren | |||||||
|   await gitCommits(['feat: feature on maintenance version 1.x'], {cwd}); |   await gitCommits(['feat: feature on maintenance version 1.x'], {cwd}); | ||||||
|   await gitPush('origin', 'master', {cwd}); |   await gitPush('origin', 'master', {cwd}); | ||||||
| 
 | 
 | ||||||
|   const verifyConditions = stub().resolves(); |   const verifyConditions = sinon.stub().resolves(); | ||||||
|   const verifyRelease = stub().resolves(); |   const verifyRelease = sinon.stub().resolves(); | ||||||
|   const addChannel = stub().resolves(); |   const addChannel = sinon.stub().resolves(); | ||||||
|   const prepare = stub().resolves(); |   const prepare = sinon.stub().resolves(); | ||||||
|   const publish = stub().resolves(); |   const publish = sinon.stub().resolves(); | ||||||
|   const success = stub().resolves(); |   const success = sinon.stub().resolves(); | ||||||
| 
 | 
 | ||||||
|   const config = { |   const config = { | ||||||
|     branches: [{name: '1.x'}, {name: 'master'}], |     branches: [{name: '1.x'}, {name: 'master'}], | ||||||
| @ -1439,12 +1439,12 @@ test('Throws "EINVALIDNEXTVERSION" if next release is out of range of the curren | |||||||
|   await gitCommits(['feat: new feature on master', 'fix: new fix on master'], {cwd}); |   await gitCommits(['feat: new feature on master', 'fix: new fix on master'], {cwd}); | ||||||
|   await gitPush('origin', 'master', {cwd}); |   await gitPush('origin', 'master', {cwd}); | ||||||
| 
 | 
 | ||||||
|   const verifyConditions = stub().resolves(); |   const verifyConditions = sinon.stub().resolves(); | ||||||
|   const verifyRelease = stub().resolves(); |   const verifyRelease = sinon.stub().resolves(); | ||||||
|   const addChannel = stub().resolves(); |   const addChannel = sinon.stub().resolves(); | ||||||
|   const prepare = stub().resolves(); |   const prepare = sinon.stub().resolves(); | ||||||
|   const publish = stub().resolves(); |   const publish = sinon.stub().resolves(); | ||||||
|   const success = stub().resolves(); |   const success = sinon.stub().resolves(); | ||||||
| 
 | 
 | ||||||
|   const config = { |   const config = { | ||||||
|     branches: [{name: 'master'}, {name: 'next'}, {name: 'next-major'}], |     branches: [{name: 'master'}, {name: 'next'}, {name: 'next-major'}], | ||||||
| @ -1497,15 +1497,15 @@ test('Throws "EINVALIDMAINTENANCEMERGE" if merge an out of range release in a ma | |||||||
|   await gitPush('origin', '1.1.x', {cwd}); |   await gitPush('origin', '1.1.x', {cwd}); | ||||||
| 
 | 
 | ||||||
|   const notes = 'Release notes'; |   const notes = 'Release notes'; | ||||||
|   const verifyConditions = stub().resolves(); |   const verifyConditions = sinon.stub().resolves(); | ||||||
|   const analyzeCommits = stub().resolves(); |   const analyzeCommits = sinon.stub().resolves(); | ||||||
|   const verifyRelease = stub().resolves(); |   const verifyRelease = sinon.stub().resolves(); | ||||||
|   const generateNotes = stub().resolves(notes); |   const generateNotes = sinon.stub().resolves(notes); | ||||||
|   const addChannel = stub().resolves(); |   const addChannel = sinon.stub().resolves(); | ||||||
|   const prepare = stub().resolves(); |   const prepare = sinon.stub().resolves(); | ||||||
|   const publish = stub().resolves(); |   const publish = sinon.stub().resolves(); | ||||||
|   const success = stub().resolves(); |   const success = sinon.stub().resolves(); | ||||||
|   const fail = stub().resolves(); |   const fail = sinon.stub().resolves(); | ||||||
| 
 | 
 | ||||||
|   const config = {branches: [{name: 'master'}, {name: '1.1.x'}], repositoryUrl, tagFormat: `v\${version}`}; |   const config = {branches: [{name: 'master'}, {name: '1.1.x'}], repositoryUrl, tagFormat: `v\${version}`}; | ||||||
|   const options = { |   const options = { | ||||||
| @ -1580,15 +1580,15 @@ test('Returns false if not running from the configured branch', async (t) => { | |||||||
|   const options = { |   const options = { | ||||||
|     branches: ['master'], |     branches: ['master'], | ||||||
|     repositoryUrl, |     repositoryUrl, | ||||||
|     verifyConditions: stub().resolves(), |     verifyConditions: sinon.stub().resolves(), | ||||||
|     analyzeCommits: stub().resolves(), |     analyzeCommits: sinon.stub().resolves(), | ||||||
|     verifyRelease: stub().resolves(), |     verifyRelease: sinon.stub().resolves(), | ||||||
|     generateNotes: stub().resolves(), |     generateNotes: sinon.stub().resolves(), | ||||||
|     addChannel: stub().resolves(), |     addChannel: sinon.stub().resolves(), | ||||||
|     prepare: stub().resolves(), |     prepare: sinon.stub().resolves(), | ||||||
|     publish: stub().resolves(), |     publish: sinon.stub().resolves(), | ||||||
|     success: stub().resolves(), |     success: sinon.stub().resolves(), | ||||||
|     fail: stub().resolves(), |     fail: sinon.stub().resolves(), | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const semanticRelease = requireNoCache('..', { |   const semanticRelease = requireNoCache('..', { | ||||||
| @ -1617,23 +1617,23 @@ test('Returns false if there is no relevant changes', async (t) => { | |||||||
|   await gitCommits(['First'], {cwd}); |   await gitCommits(['First'], {cwd}); | ||||||
|   await gitPush(repositoryUrl, 'master', {cwd}); |   await gitPush(repositoryUrl, 'master', {cwd}); | ||||||
| 
 | 
 | ||||||
|   const analyzeCommits = stub().resolves(); |   const analyzeCommits = sinon.stub().resolves(); | ||||||
|   const verifyRelease = stub().resolves(); |   const verifyRelease = sinon.stub().resolves(); | ||||||
|   const generateNotes = stub().resolves(); |   const generateNotes = sinon.stub().resolves(); | ||||||
|   const publish = stub().resolves(); |   const publish = sinon.stub().resolves(); | ||||||
| 
 | 
 | ||||||
|   const options = { |   const options = { | ||||||
|     branches: ['master'], |     branches: ['master'], | ||||||
|     repositoryUrl, |     repositoryUrl, | ||||||
|     verifyConditions: [stub().resolves()], |     verifyConditions: [sinon.stub().resolves()], | ||||||
|     analyzeCommits, |     analyzeCommits, | ||||||
|     verifyRelease, |     verifyRelease, | ||||||
|     generateNotes, |     generateNotes, | ||||||
|     addChannel: stub().resolves(), |     addChannel: sinon.stub().resolves(), | ||||||
|     prepare: stub().resolves(), |     prepare: sinon.stub().resolves(), | ||||||
|     publish, |     publish, | ||||||
|     success: stub().resolves(), |     success: sinon.stub().resolves(), | ||||||
|     fail: stub().resolves(), |     fail: sinon.stub().resolves(), | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const semanticRelease = requireNoCache('..', { |   const semanticRelease = requireNoCache('..', { | ||||||
| @ -1677,19 +1677,19 @@ test('Exclude commits with [skip release] or [release skip] from analysis', asyn | |||||||
|     {cwd} |     {cwd} | ||||||
|   ); |   ); | ||||||
|   await gitPush(repositoryUrl, 'master', {cwd}); |   await gitPush(repositoryUrl, 'master', {cwd}); | ||||||
|   const analyzeCommits = stub().resolves(); |   const analyzeCommits = sinon.stub().resolves(); | ||||||
|   const config = {branches: ['master'], repositoryUrl, globalOpt: 'global'}; |   const config = {branches: ['master'], repositoryUrl, globalOpt: 'global'}; | ||||||
|   const options = { |   const options = { | ||||||
|     ...config, |     ...config, | ||||||
|     verifyConditions: [stub().resolves(), stub().resolves()], |     verifyConditions: [sinon.stub().resolves(), sinon.stub().resolves()], | ||||||
|     analyzeCommits, |     analyzeCommits, | ||||||
|     verifyRelease: stub().resolves(), |     verifyRelease: sinon.stub().resolves(), | ||||||
|     generateNotes: stub().resolves(), |     generateNotes: sinon.stub().resolves(), | ||||||
|     addChannel: stub().resolves(), |     addChannel: sinon.stub().resolves(), | ||||||
|     prepare: stub().resolves(), |     prepare: sinon.stub().resolves(), | ||||||
|     publish: stub().resolves(), |     publish: sinon.stub().resolves(), | ||||||
|     success: stub().resolves(), |     success: sinon.stub().resolves(), | ||||||
|     fail: stub().resolves(), |     fail: sinon.stub().resolves(), | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const semanticRelease = requireNoCache('..', { |   const semanticRelease = requireNoCache('..', { | ||||||
| @ -1717,8 +1717,8 @@ test('Log both plugins errors and errors thrown by "fail" plugin', async (t) => | |||||||
|   const options = { |   const options = { | ||||||
|     branches: ['master'], |     branches: ['master'], | ||||||
|     repositoryUrl, |     repositoryUrl, | ||||||
|     verifyConditions: stub().rejects(pluginError), |     verifyConditions: sinon.stub().rejects(pluginError), | ||||||
|     fail: [stub().rejects(failError1), stub().rejects(failError2)], |     fail: [sinon.stub().rejects(failError1), sinon.stub().rejects(failError2)], | ||||||
|   }; |   }; | ||||||
|   const semanticRelease = requireNoCache('..', { |   const semanticRelease = requireNoCache('..', { | ||||||
|     './lib/get-logger': () => t.context.logger, |     './lib/get-logger': () => t.context.logger, | ||||||
| @ -1737,12 +1737,12 @@ test('Log both plugins errors and errors thrown by "fail" plugin', async (t) => | |||||||
| test('Call "fail" only if a plugin returns a SemanticReleaseError', async (t) => { | test('Call "fail" only if a plugin returns a SemanticReleaseError', async (t) => { | ||||||
|   const {cwd, repositoryUrl} = await gitRepo(true); |   const {cwd, repositoryUrl} = await gitRepo(true); | ||||||
|   const pluginError = new Error('Plugin error'); |   const pluginError = new Error('Plugin error'); | ||||||
|   const fail = stub().resolves(); |   const fail = sinon.stub().resolves(); | ||||||
| 
 | 
 | ||||||
|   const options = { |   const options = { | ||||||
|     branches: ['master'], |     branches: ['master'], | ||||||
|     repositoryUrl, |     repositoryUrl, | ||||||
|     verifyConditions: stub().rejects(pluginError), |     verifyConditions: sinon.stub().rejects(pluginError), | ||||||
|     fail, |     fail, | ||||||
|   }; |   }; | ||||||
|   const semanticRelease = requireNoCache('..', { |   const semanticRelease = requireNoCache('..', { | ||||||
| @ -1790,16 +1790,16 @@ test('Throw an Error if plugin returns an unexpected value', async (t) => { | |||||||
|   await gitCommits(['Second'], {cwd}); |   await gitCommits(['Second'], {cwd}); | ||||||
|   await gitPush(repositoryUrl, 'master', {cwd}); |   await gitPush(repositoryUrl, 'master', {cwd}); | ||||||
| 
 | 
 | ||||||
|   const verifyConditions = stub().resolves(); |   const verifyConditions = sinon.stub().resolves(); | ||||||
|   const analyzeCommits = stub().resolves('string'); |   const analyzeCommits = sinon.stub().resolves('string'); | ||||||
| 
 | 
 | ||||||
|   const options = { |   const options = { | ||||||
|     branches: ['master'], |     branches: ['master'], | ||||||
|     repositoryUrl, |     repositoryUrl, | ||||||
|     verifyConditions: [verifyConditions], |     verifyConditions: [verifyConditions], | ||||||
|     analyzeCommits, |     analyzeCommits, | ||||||
|     success: stub().resolves(), |     success: sinon.stub().resolves(), | ||||||
|     fail: stub().resolves(), |     fail: sinon.stub().resolves(), | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const semanticRelease = requireNoCache('..', { |   const semanticRelease = requireNoCache('..', { | ||||||
| @ -1816,19 +1816,19 @@ test('Throw an Error if plugin returns an unexpected value', async (t) => { | |||||||
| test('Hide sensitive information passed to "fail" plugin', async (t) => { | test('Hide sensitive information passed to "fail" plugin', async (t) => { | ||||||
|   const {cwd, repositoryUrl} = await gitRepo(true); |   const {cwd, repositoryUrl} = await gitRepo(true); | ||||||
| 
 | 
 | ||||||
|   const fail = stub().resolves(); |   const fail = sinon.stub().resolves(); | ||||||
|   const env = {MY_TOKEN: 'secret token'}; |   const env = {MY_TOKEN: 'secret token'}; | ||||||
|   const options = { |   const options = { | ||||||
|     branch: 'master', |     branch: 'master', | ||||||
|     repositoryUrl, |     repositoryUrl, | ||||||
|     verifyConditions: stub().throws( |     verifyConditions: sinon.stub().throws( | ||||||
|       new SemanticReleaseError( |       new SemanticReleaseError( | ||||||
|         `Message: Exposing token ${env.MY_TOKEN}`, |         `Message: Exposing token ${env.MY_TOKEN}`, | ||||||
|         'ERR', |         'ERR', | ||||||
|         `Details: Exposing token ${env.MY_TOKEN}` |         `Details: Exposing token ${env.MY_TOKEN}` | ||||||
|       ) |       ) | ||||||
|     ), |     ), | ||||||
|     success: stub().resolves(), |     success: sinon.stub().resolves(), | ||||||
|     fail, |     fail, | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
| @ -1859,7 +1859,7 @@ test('Hide sensitive information passed to "success" plugin', async (t) => { | |||||||
|   await gitCommits(['feat: new feature'], {cwd}); |   await gitCommits(['feat: new feature'], {cwd}); | ||||||
|   await gitPush(repositoryUrl, 'master', {cwd}); |   await gitPush(repositoryUrl, 'master', {cwd}); | ||||||
| 
 | 
 | ||||||
|   const success = stub().resolves(); |   const success = sinon.stub().resolves(); | ||||||
|   const env = {MY_TOKEN: 'secret token'}; |   const env = {MY_TOKEN: 'secret token'}; | ||||||
|   const options = { |   const options = { | ||||||
|     branch: 'master', |     branch: 'master', | ||||||
| @ -1867,14 +1867,14 @@ test('Hide sensitive information passed to "success" plugin', async (t) => { | |||||||
|     verifyConditions: false, |     verifyConditions: false, | ||||||
|     verifyRelease: false, |     verifyRelease: false, | ||||||
|     prepare: false, |     prepare: false, | ||||||
|     generateNotes: stub().resolves(`Exposing token ${env.MY_TOKEN}`), |     generateNotes: sinon.stub().resolves(`Exposing token ${env.MY_TOKEN}`), | ||||||
|     publish: stub().resolves({ |     publish: sinon.stub().resolves({ | ||||||
|       name: `Name: Exposing token ${env.MY_TOKEN}`, |       name: `Name: Exposing token ${env.MY_TOKEN}`, | ||||||
|       url: `URL: Exposing token ${env.MY_TOKEN}`, |       url: `URL: Exposing token ${env.MY_TOKEN}`, | ||||||
|     }), |     }), | ||||||
|     addChannel: false, |     addChannel: false, | ||||||
|     success, |     success, | ||||||
|     fail: stub().resolves(), |     fail: sinon.stub().resolves(), | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const semanticRelease = requireNoCache('..', { |   const semanticRelease = requireNoCache('..', { | ||||||
| @ -1912,19 +1912,19 @@ test('Get all commits including the ones not in the shallow clone', async (t) => | |||||||
|     channel: undefined, |     channel: undefined, | ||||||
|   }; |   }; | ||||||
|   const notes = 'Release notes'; |   const notes = 'Release notes'; | ||||||
|   const analyzeCommits = stub().resolves(nextRelease.type); |   const analyzeCommits = sinon.stub().resolves(nextRelease.type); | ||||||
| 
 | 
 | ||||||
|   const config = {branches: ['master'], repositoryUrl, globalOpt: 'global'}; |   const config = {branches: ['master'], repositoryUrl, globalOpt: 'global'}; | ||||||
|   const options = { |   const options = { | ||||||
|     ...config, |     ...config, | ||||||
|     verifyConditions: stub().resolves(), |     verifyConditions: sinon.stub().resolves(), | ||||||
|     analyzeCommits, |     analyzeCommits, | ||||||
|     verifyRelease: stub().resolves(), |     verifyRelease: sinon.stub().resolves(), | ||||||
|     generateNotes: stub().resolves(notes), |     generateNotes: sinon.stub().resolves(notes), | ||||||
|     prepare: stub().resolves(), |     prepare: sinon.stub().resolves(), | ||||||
|     publish: stub().resolves(), |     publish: sinon.stub().resolves(), | ||||||
|     success: stub().resolves(), |     success: sinon.stub().resolves(), | ||||||
|     fail: stub().resolves(), |     fail: sinon.stub().resolves(), | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const semanticRelease = requireNoCache('..', { |   const semanticRelease = requireNoCache('..', { | ||||||
|  | |||||||
| @ -1,16 +1,16 @@ | |||||||
| import test from 'ava'; | import test from 'ava'; | ||||||
| import {noop} from 'lodash'; | import {noop} from 'lodash'; | ||||||
| import {stub} from 'sinon'; | import sinon from 'sinon'; | ||||||
| import normalize from '../../lib/plugins/normalize.js'; | import normalize from '../../lib/plugins/normalize.js'; | ||||||
| 
 | 
 | ||||||
| const cwd = process.cwd(); | const cwd = process.cwd(); | ||||||
| 
 | 
 | ||||||
| test.beforeEach((t) => { | test.beforeEach((t) => { | ||||||
|   // Stub the logger functions
 |   // Stub the logger functions
 | ||||||
|   t.context.log = stub(); |   t.context.log = sinon.stub); | ||||||
|   t.context.error = stub(); |   t.context.error = sinon.stub); | ||||||
|   t.context.success = stub(); |   t.context.success = sinon.stub); | ||||||
|   t.context.stderr = {write: stub()}; |   t.context.stderr = {write: sinon.stub)}; | ||||||
|   t.context.logger = { |   t.context.logger = { | ||||||
|     log: t.context.log, |     log: t.context.log, | ||||||
|     error: t.context.error, |     error: t.context.error, | ||||||
| @ -99,7 +99,7 @@ test('Normalize and load plugin that retuns multiple functions', (t) => { | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test('Wrap "analyzeCommits" plugin in a function that validate the output of the plugin', async (t) => { | test('Wrap "analyzeCommits" plugin in a function that validate the output of the plugin', async (t) => { | ||||||
|   const analyzeCommits = stub().resolves(2); |   const analyzeCommits = sinon.stub).resolves(2); | ||||||
|   const plugin = normalize( |   const plugin = normalize( | ||||||
|     {cwd, options: {}, stderr: t.context.stderr, logger: t.context.logger}, |     {cwd, options: {}, stderr: t.context.stderr, logger: t.context.logger}, | ||||||
|     'analyzeCommits', |     'analyzeCommits', | ||||||
| @ -117,7 +117,7 @@ test('Wrap "analyzeCommits" plugin in a function that validate the output of the | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test('Wrap "generateNotes" plugin in a function that validate the output of the plugin', async (t) => { | test('Wrap "generateNotes" plugin in a function that validate the output of the plugin', async (t) => { | ||||||
|   const generateNotes = stub().resolves(2); |   const generateNotes = sinon.stub).resolves(2); | ||||||
|   const plugin = normalize( |   const plugin = normalize( | ||||||
|     {cwd, options: {}, stderr: t.context.stderr, logger: t.context.logger}, |     {cwd, options: {}, stderr: t.context.stderr, logger: t.context.logger}, | ||||||
|     'generateNotes', |     'generateNotes', | ||||||
| @ -135,7 +135,7 @@ test('Wrap "generateNotes" plugin in a function that validate the output of the | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test('Wrap "publish" plugin in a function that validate the output of the plugin', async (t) => { | test('Wrap "publish" plugin in a function that validate the output of the plugin', async (t) => { | ||||||
|   const publish = stub().resolves(2); |   const publish = sinon.stub).resolves(2); | ||||||
|   const plugin = normalize( |   const plugin = normalize( | ||||||
|     {cwd, options: {}, stderr: t.context.stderr, logger: t.context.logger}, |     {cwd, options: {}, stderr: t.context.stderr, logger: t.context.logger}, | ||||||
|     'publish', |     'publish', | ||||||
| @ -153,7 +153,7 @@ test('Wrap "publish" plugin in a function that validate the output of the plugin | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test('Wrap "addChannel" plugin in a function that validate the output of the plugin', async (t) => { | test('Wrap "addChannel" plugin in a function that validate the output of the plugin', async (t) => { | ||||||
|   const addChannel = stub().resolves(2); |   const addChannel = sinon.stub).resolves(2); | ||||||
|   const plugin = normalize( |   const plugin = normalize( | ||||||
|     {cwd, options: {}, stderr: t.context.stderr, logger: t.context.logger}, |     {cwd, options: {}, stderr: t.context.stderr, logger: t.context.logger}, | ||||||
|     'addChannel', |     'addChannel', | ||||||
| @ -171,7 +171,7 @@ test('Wrap "addChannel" plugin in a function that validate the output of the plu | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test('Plugin is called with "pluginConfig" (with object definition) and input', async (t) => { | test('Plugin is called with "pluginConfig" (with object definition) and input', async (t) => { | ||||||
|   const pluginFunction = stub().resolves(); |   const pluginFunction = sinon.stub).resolves(); | ||||||
|   const pluginConf = {path: pluginFunction, conf: 'confValue'}; |   const pluginConf = {path: pluginFunction, conf: 'confValue'}; | ||||||
|   const options = {global: 'globalValue'}; |   const options = {global: 'globalValue'}; | ||||||
|   const plugin = normalize({cwd, options, logger: t.context.logger}, '', pluginConf, {}); |   const plugin = normalize({cwd, options, logger: t.context.logger}, '', pluginConf, {}); | ||||||
| @ -186,7 +186,7 @@ test('Plugin is called with "pluginConfig" (with object definition) and input', | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test('Plugin is called with "pluginConfig" (with array definition) and input', async (t) => { | test('Plugin is called with "pluginConfig" (with array definition) and input', async (t) => { | ||||||
|   const pluginFunction = stub().resolves(); |   const pluginFunction = sinon.stub).resolves(); | ||||||
|   const pluginConf = [pluginFunction, {conf: 'confValue'}]; |   const pluginConf = [pluginFunction, {conf: 'confValue'}]; | ||||||
|   const options = {global: 'globalValue'}; |   const options = {global: 'globalValue'}; | ||||||
|   const plugin = normalize({cwd, options, logger: t.context.logger}, '', pluginConf, {}); |   const plugin = normalize({cwd, options, logger: t.context.logger}, '', pluginConf, {}); | ||||||
| @ -201,7 +201,7 @@ test('Plugin is called with "pluginConfig" (with array definition) and input', a | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test('Prevent plugins to modify "pluginConfig"', async (t) => { | test('Prevent plugins to modify "pluginConfig"', async (t) => { | ||||||
|   const pluginFunction = stub().callsFake((pluginConfig) => { |   const pluginFunction = sinon.stub).callsFake((pluginConfig) => { | ||||||
|     pluginConfig.conf.subConf = 'otherConf'; |     pluginConfig.conf.subConf = 'otherConf'; | ||||||
|   }); |   }); | ||||||
|   const pluginConf = {path: pluginFunction, conf: {subConf: 'originalConf'}}; |   const pluginConf = {path: pluginFunction, conf: {subConf: 'originalConf'}}; | ||||||
| @ -214,7 +214,7 @@ test('Prevent plugins to modify "pluginConfig"', async (t) => { | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test('Prevent plugins to modify its input', async (t) => { | test('Prevent plugins to modify its input', async (t) => { | ||||||
|   const pluginFunction = stub().callsFake((pluginConfig, options) => { |   const pluginFunction = sinon.stub).callsFake((pluginConfig, options) => { | ||||||
|     options.param.subParam = 'otherParam'; |     options.param.subParam = 'otherParam'; | ||||||
|   }); |   }); | ||||||
|   const input = {param: {subParam: 'originalSubParam'}, options: {}}; |   const input = {param: {subParam: 'originalSubParam'}, options: {}}; | ||||||
|  | |||||||
| @ -1,12 +1,12 @@ | |||||||
| import test from 'ava'; | import test from 'ava'; | ||||||
| import {stub} from 'sinon'; | import sinon from 'sinon'; | ||||||
| import AggregateError from 'aggregate-error'; | import AggregateError from 'aggregate-error'; | ||||||
| import pipeline from '../../lib/plugins/pipeline.js'; | import pipeline from '../../lib/plugins/pipeline.js'; | ||||||
| 
 | 
 | ||||||
| test('Execute each function in series passing the same input', async (t) => { | test('Execute each function in series passing the same input', async (t) => { | ||||||
|   const step1 = stub().resolves(1); |   const step1 = sinon.stub).resolves(1); | ||||||
|   const step2 = stub().resolves(2); |   const step2 = sinon.stub).resolves(2); | ||||||
|   const step3 = stub().resolves(3); |   const step3 = sinon.stub).resolves(3); | ||||||
| 
 | 
 | ||||||
|   const result = await pipeline([step1, step2, step3])(0); |   const result = await pipeline([step1, step2, step3])(0); | ||||||
|   t.deepEqual(result, [1, 2, 3]); |   t.deepEqual(result, [1, 2, 3]); | ||||||
| @ -19,10 +19,10 @@ test('Execute each function in series passing the same input', async (t) => { | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test('Execute each function in series passing a transformed input from "getNextInput"', async (t) => { | test('Execute each function in series passing a transformed input from "getNextInput"', async (t) => { | ||||||
|   const step1 = stub().resolves(1); |   const step1 = sinon.stub).resolves(1); | ||||||
|   const step2 = stub().resolves(2); |   const step2 = sinon.stub).resolves(2); | ||||||
|   const step3 = stub().resolves(3); |   const step3 = sinon.stub).resolves(3); | ||||||
|   const step4 = stub().resolves(4); |   const step4 = sinon.stub).resolves(4); | ||||||
|   const getNextInput = (lastResult, result) => lastResult + result; |   const getNextInput = (lastResult, result) => lastResult + result; | ||||||
| 
 | 
 | ||||||
|   const result = await pipeline([step1, step2, step3, step4], {settleAll: false, getNextInput})(0); |   const result = await pipeline([step1, step2, step3, step4], {settleAll: false, getNextInput})(0); | ||||||
| @ -38,11 +38,11 @@ test('Execute each function in series passing a transformed input from "getNextI | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test('Execute each function in series passing the "lastResult" and "result" to "getNextInput"', async (t) => { | test('Execute each function in series passing the "lastResult" and "result" to "getNextInput"', async (t) => { | ||||||
|   const step1 = stub().resolves(1); |   const step1 = sinon.stub).resolves(1); | ||||||
|   const step2 = stub().resolves(2); |   const step2 = sinon.stub).resolves(2); | ||||||
|   const step3 = stub().resolves(3); |   const step3 = sinon.stub).resolves(3); | ||||||
|   const step4 = stub().resolves(4); |   const step4 = sinon.stub).resolves(4); | ||||||
|   const getNextInput = stub().returnsArg(0); |   const getNextInput = sinon.stub).returnsArg(0); | ||||||
| 
 | 
 | ||||||
|   const result = await pipeline([step1, step2, step3, step4], {settleAll: false, getNextInput})(5); |   const result = await pipeline([step1, step2, step3, step4], {settleAll: false, getNextInput})(5); | ||||||
| 
 | 
 | ||||||
| @ -56,12 +56,12 @@ test('Execute each function in series passing the "lastResult" and "result" to " | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test('Execute each function in series calling "transform" to modify the results', async (t) => { | test('Execute each function in series calling "transform" to modify the results', async (t) => { | ||||||
|   const step1 = stub().resolves(1); |   const step1 = sinon.stub).resolves(1); | ||||||
|   const step2 = stub().resolves(2); |   const step2 = sinon.stub).resolves(2); | ||||||
|   const step3 = stub().resolves(3); |   const step3 = sinon.stub).resolves(3); | ||||||
|   const step4 = stub().resolves(4); |   const step4 = sinon.stub).resolves(4); | ||||||
|   const getNextInput = stub().returnsArg(0); |   const getNextInput = sinon.stub).returnsArg(0); | ||||||
|   const transform = stub().callsFake((result) => result + 1); |   const transform = sinon.stub).callsFake((result) => result + 1); | ||||||
| 
 | 
 | ||||||
|   const result = await pipeline([step1, step2, step3, step4], {getNextInput, transform})(5); |   const result = await pipeline([step1, step2, step3, step4], {getNextInput, transform})(5); | ||||||
| 
 | 
 | ||||||
| @ -75,12 +75,12 @@ test('Execute each function in series calling "transform" to modify the results' | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test('Execute each function in series calling "transform" to modify the results with "settleAll"', async (t) => { | test('Execute each function in series calling "transform" to modify the results with "settleAll"', async (t) => { | ||||||
|   const step1 = stub().resolves(1); |   const step1 = sinon.stub).resolves(1); | ||||||
|   const step2 = stub().resolves(2); |   const step2 = sinon.stub).resolves(2); | ||||||
|   const step3 = stub().resolves(3); |   const step3 = sinon.stub).resolves(3); | ||||||
|   const step4 = stub().resolves(4); |   const step4 = sinon.stub).resolves(4); | ||||||
|   const getNextInput = stub().returnsArg(0); |   const getNextInput = sinon.stub).returnsArg(0); | ||||||
|   const transform = stub().callsFake((result) => result + 1); |   const transform = sinon.stub).callsFake((result) => result + 1); | ||||||
| 
 | 
 | ||||||
|   const result = await pipeline([step1, step2, step3, step4], {settleAll: true, getNextInput, transform})(5); |   const result = await pipeline([step1, step2, step3, step4], {settleAll: true, getNextInput, transform})(5); | ||||||
| 
 | 
 | ||||||
| @ -94,9 +94,9 @@ test('Execute each function in series calling "transform" to modify the results | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test('Stop execution and throw error if a step rejects', async (t) => { | test('Stop execution and throw error if a step rejects', async (t) => { | ||||||
|   const step1 = stub().resolves(1); |   const step1 = sinon.stub).resolves(1); | ||||||
|   const step2 = stub().rejects(new Error('test error')); |   const step2 = sinon.stub).rejects(new Error('test error')); | ||||||
|   const step3 = stub().resolves(3); |   const step3 = sinon.stub).resolves(3); | ||||||
| 
 | 
 | ||||||
|   const error = await t.throwsAsync(pipeline([step1, step2, step3])(0), { |   const error = await t.throwsAsync(pipeline([step1, step2, step3])(0), { | ||||||
|     instanceOf: Error, |     instanceOf: Error, | ||||||
| @ -112,9 +112,9 @@ test('Throw all errors from the first step throwing an AggregateError', async (t | |||||||
|   const error1 = new Error('test error 1'); |   const error1 = new Error('test error 1'); | ||||||
|   const error2 = new Error('test error 2'); |   const error2 = new Error('test error 2'); | ||||||
| 
 | 
 | ||||||
|   const step1 = stub().resolves(1); |   const step1 = sinon.stub).resolves(1); | ||||||
|   const step2 = stub().rejects(new AggregateError([error1, error2])); |   const step2 = sinon.stub).rejects(new AggregateError([error1, error2])); | ||||||
|   const step3 = stub().resolves(3); |   const step3 = sinon.stub).resolves(3); | ||||||
| 
 | 
 | ||||||
|   const errors = await t.throwsAsync(pipeline([step1, step2, step3])(0)); |   const errors = await t.throwsAsync(pipeline([step1, step2, step3])(0)); | ||||||
| 
 | 
 | ||||||
| @ -127,9 +127,9 @@ test('Throw all errors from the first step throwing an AggregateError', async (t | |||||||
| test('Execute all even if a Promise rejects', async (t) => { | test('Execute all even if a Promise rejects', async (t) => { | ||||||
|   const error1 = new Error('test error 1'); |   const error1 = new Error('test error 1'); | ||||||
|   const error2 = new Error('test error 2'); |   const error2 = new Error('test error 2'); | ||||||
|   const step1 = stub().resolves(1); |   const step1 = sinon.stub).resolves(1); | ||||||
|   const step2 = stub().rejects(error1); |   const step2 = sinon.stub).rejects(error1); | ||||||
|   const step3 = stub().rejects(error2); |   const step3 = sinon.stub).rejects(error2); | ||||||
| 
 | 
 | ||||||
|   const errors = await t.throwsAsync(pipeline([step1, step2, step3], {settleAll: true})(0)); |   const errors = await t.throwsAsync(pipeline([step1, step2, step3], {settleAll: true})(0)); | ||||||
| 
 | 
 | ||||||
| @ -144,8 +144,8 @@ test('Throw all errors from all steps throwing an AggregateError', async (t) => | |||||||
|   const error2 = new Error('test error 2'); |   const error2 = new Error('test error 2'); | ||||||
|   const error3 = new Error('test error 3'); |   const error3 = new Error('test error 3'); | ||||||
|   const error4 = new Error('test error 4'); |   const error4 = new Error('test error 4'); | ||||||
|   const step1 = stub().rejects(new AggregateError([error1, error2])); |   const step1 = sinon.stub).rejects(new AggregateError([error1, error2])); | ||||||
|   const step2 = stub().rejects(new AggregateError([error3, error4])); |   const step2 = sinon.stub).rejects(new AggregateError([error3, error4])); | ||||||
| 
 | 
 | ||||||
|   const errors = await t.throwsAsync(pipeline([step1, step2], {settleAll: true})(0)); |   const errors = await t.throwsAsync(pipeline([step1, step2], {settleAll: true})(0)); | ||||||
| 
 | 
 | ||||||
| @ -157,10 +157,10 @@ test('Throw all errors from all steps throwing an AggregateError', async (t) => | |||||||
| test('Execute each function in series passing a transformed input even if a step rejects', async (t) => { | test('Execute each function in series passing a transformed input even if a step rejects', async (t) => { | ||||||
|   const error2 = new Error('test error 2'); |   const error2 = new Error('test error 2'); | ||||||
|   const error3 = new Error('test error 3'); |   const error3 = new Error('test error 3'); | ||||||
|   const step1 = stub().resolves(1); |   const step1 = sinon.stub).resolves(1); | ||||||
|   const step2 = stub().rejects(error2); |   const step2 = sinon.stub).rejects(error2); | ||||||
|   const step3 = stub().rejects(error3); |   const step3 = sinon.stub).rejects(error3); | ||||||
|   const step4 = stub().resolves(4); |   const step4 = sinon.stub).resolves(4); | ||||||
|   const getNextInput = (previousResult, result) => previousResult + result; |   const getNextInput = (previousResult, result) => previousResult + result; | ||||||
| 
 | 
 | ||||||
|   const errors = await t.throwsAsync(pipeline([step1, step2, step3, step4], {settleAll: true, getNextInput})(0)); |   const errors = await t.throwsAsync(pipeline([step1, step2, step3, step4], {settleAll: true, getNextInput})(0)); | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| import path from 'path'; | import path from 'path'; | ||||||
| import test from 'ava'; | import test from 'ava'; | ||||||
| import {copy, outputFile} from 'fs-extra'; | import {copy, outputFile} from 'fs-extra'; | ||||||
| import {stub} from 'sinon'; | import sinon from 'sinon'; | ||||||
| import tempy from 'tempy'; | import tempy from 'tempy'; | ||||||
| import getPlugins from '../../lib/plugins'; | import getPlugins from '../../lib/plugins'; | ||||||
| 
 | 
 | ||||||
| @ -10,8 +10,8 @@ const cwd = process.cwd(); | |||||||
| 
 | 
 | ||||||
| test.beforeEach((t) => { | test.beforeEach((t) => { | ||||||
|   // Stub the logger functions
 |   // Stub the logger functions
 | ||||||
|   t.context.log = stub(); |   t.context.log = sinon.stub); | ||||||
|   t.context.success = stub(); |   t.context.success = sinon.stub); | ||||||
|   t.context.logger = {log: t.context.log, success: t.context.success, scope: () => t.context.logger}; |   t.context.logger = {log: t.context.log, success: t.context.success, scope: () => t.context.logger}; | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| @ -56,8 +56,8 @@ test('Export plugins based on steps config', (t) => { | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test('Export plugins based on "plugins" config (array)', async (t) => { | test('Export plugins based on "plugins" config (array)', async (t) => { | ||||||
|   const plugin1 = {verifyConditions: stub(), publish: stub()}; |   const plugin1 = {verifyConditions: sinon.stub), publish: sinon.stub)}; | ||||||
|   const plugin2 = {verifyConditions: stub(), verifyRelease: stub()}; |   const plugin2 = {verifyConditions: sinon.stub), verifyRelease: sinon.stub)}; | ||||||
|   const plugins = getPlugins( |   const plugins = getPlugins( | ||||||
|     {cwd, logger: t.context.logger, options: {plugins: [plugin1, [plugin2, {}]], verifyRelease: () => {}}}, |     {cwd, logger: t.context.logger, options: {plugins: [plugin1, [plugin2, {}]], verifyRelease: () => {}}}, | ||||||
|     {} |     {} | ||||||
| @ -85,7 +85,7 @@ test('Export plugins based on "plugins" config (array)', async (t) => { | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test('Export plugins based on "plugins" config (single definition)', async (t) => { | test('Export plugins based on "plugins" config (single definition)', async (t) => { | ||||||
|   const plugin1 = {verifyConditions: stub(), publish: stub()}; |   const plugin1 = {verifyConditions: sinon.stub), publish: sinon.stub)}; | ||||||
|   const plugins = getPlugins({cwd, logger: t.context.logger, options: {plugins: plugin1}}, {}); |   const plugins = getPlugins({cwd, logger: t.context.logger, options: {plugins: plugin1}}, {}); | ||||||
| 
 | 
 | ||||||
|   await plugins.verifyConditions({options: {}}); |   await plugins.verifyConditions({options: {}}); | ||||||
| @ -106,8 +106,8 @@ test('Export plugins based on "plugins" config (single definition)', async (t) = | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test('Merge global options, "plugins" options and step options', async (t) => { | test('Merge global options, "plugins" options and step options', async (t) => { | ||||||
|   const plugin1 = [{verifyConditions: stub(), publish: stub()}, {pluginOpt1: 'plugin1'}]; |   const plugin1 = [{verifyConditions: sinon.stub), publish: sinon.stub)}, {pluginOpt1: 'plugin1'}]; | ||||||
|   const plugin2 = [{verifyConditions: stub()}, {pluginOpt2: 'plugin2'}]; |   const plugin2 = [{verifyConditions: sinon.stub)}, {pluginOpt2: 'plugin2'}]; | ||||||
|   const plugin3 = [stub(), {pluginOpt3: 'plugin3'}]; |   const plugin3 = [stub(), {pluginOpt3: 'plugin3'}]; | ||||||
|   const plugins = getPlugins( |   const plugins = getPlugins( | ||||||
|     { |     { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user