From 20e7a38cdb5af95f5af98153765060b182d198e3 Mon Sep 17 00:00:00 2001 From: Pierre Vanduynslager Date: Wed, 20 Nov 2019 14:03:22 -0500 Subject: [PATCH] style: prettier formatting --- lib/git.js | 12 ++++---- test/branches/branches.test.js | 10 +++++-- test/branches/get-tags.test.js | 5 +++- test/branches/normalize.test.js | 47 +++++++++++++++++++++----------- test/get-releases-to-add.test.js | 11 ++++++-- test/helpers/git-utils.js | 8 ++++-- test/plugins/pipeline.test.js | 21 ++++++++++++-- 7 files changed, 82 insertions(+), 32 deletions(-) diff --git a/lib/git.js b/lib/git.js index a2956dde..58304df6 100644 --- a/lib/git.js +++ b/lib/git.js @@ -42,12 +42,14 @@ async function getTags(branch, execaOpts) { * @return {Promise>} The list of commits between `from` and `to`. */ async function getCommits(from, to, execaOpts) { - return (await getStream.array( - gitLogParser.parse( - {_: `${from ? from + '..' : ''}${to}`}, - {cwd: execaOpts.cwd, env: {...process.env, ...execaOpts.env}} + return ( + await getStream.array( + gitLogParser.parse( + {_: `${from ? from + '..' : ''}${to}`}, + {cwd: execaOpts.cwd, env: {...process.env, ...execaOpts.env}} + ) ) - )).map(({message, gitTags, ...commit}) => ({...commit, message: message.trim(), gitTags: gitTags.trim()})); + ).map(({message, gitTags, ...commit}) => ({...commit, message: message.trim(), gitTags: gitTags.trim()})); } /** diff --git a/test/branches/branches.test.js b/test/branches/branches.test.js index 339099ef..76ed0dd1 100644 --- a/test/branches/branches.test.js +++ b/test/branches/branches.test.js @@ -171,7 +171,10 @@ test('Throw SemanticReleaseError for invalid configurations', async t => { }); test('Throw a SemanticReleaseError if there is duplicate branches', async t => { - const branches = [{name: 'master', tags: []}, {name: 'master', tags: []}]; + const branches = [ + {name: 'master', tags: []}, + {name: 'master', tags: []}, + ]; const getBranches = proxyquire('../../lib/branches', {'./get-tags': () => branches, './expand': () => []}); const errors = [...(await t.throwsAsync(getBranches('repositoryUrl', {options: {branches}})))]; @@ -183,7 +186,10 @@ test('Throw a SemanticReleaseError if there is duplicate branches', async t => { }); test('Throw a SemanticReleaseError for each invalid branch name', async t => { - const branches = [{name: '~master', tags: []}, {name: '^master', tags: []}]; + const branches = [ + {name: '~master', tags: []}, + {name: '^master', tags: []}, + ]; const getBranches = proxyquire('../../lib/branches', {'./get-tags': () => branches, './expand': () => []}); const errors = [...(await t.throwsAsync(getBranches('repositoryUrl', {options: {branches}})))]; diff --git a/test/branches/get-tags.test.js b/test/branches/get-tags.test.js index ab751631..699886c7 100644 --- a/test/branches/get-tags.test.js +++ b/test/branches/get-tags.test.js @@ -129,7 +129,10 @@ test('Return branches with and empty tags array if no valid tag is found in hist const result = await getTags({cwd, options: {tagFormat: `prefix@v\${version}`}}, [{name: 'master'}, {name: 'next'}]); - t.deepEqual(result, [{name: 'master', tags: []}, {name: 'next', tags: []}]); + t.deepEqual(result, [ + {name: 'master', tags: []}, + {name: 'next', tags: []}, + ]); }); test('Get the highest valid tag corresponding to the "tagFormat"', async t => { diff --git a/test/branches/normalize.test.js b/test/branches/normalize.test.js index 03162060..d137af41 100644 --- a/test/branches/normalize.test.js +++ b/test/branches/normalize.test.js @@ -4,7 +4,11 @@ import normalize from '../../lib/branches/normalize'; const toTags = versions => versions.map(version => ({version})); test('Maintenance branches - initial state', t => { - const maintenance = [{name: '1.x', channel: '1.x', tags: []}, {name: '1.1.x', tags: []}, {name: '1.2.x', tags: []}]; + const maintenance = [ + {name: '1.x', channel: '1.x', tags: []}, + {name: '1.1.x', tags: []}, + {name: '1.2.x', tags: []}, + ]; const release = [{name: 'master', tags: []}]; t.deepEqual( normalize.maintenance({maintenance, release}).map(({type, name, range, accept, channel, mergeRange}) => ({ @@ -303,24 +307,35 @@ test('Prerelease branches', t => { {name: 'alpha', prerelease: 'preview', tags: []}, ]; - t.deepEqual(normalize.prerelease({prerelease}).map(({type, name, channel}) => ({type, name, channel})), [ - {type: 'prerelease', name: 'beta', channel: 'beta'}, - {type: 'prerelease', name: 'alpha', channel: 'alpha'}, - ]); + t.deepEqual( + normalize.prerelease({prerelease}).map(({type, name, channel}) => ({type, name, channel})), + [ + {type: 'prerelease', name: 'beta', channel: 'beta'}, + {type: 'prerelease', name: 'alpha', channel: 'alpha'}, + ] + ); }); test('Allow to set channel to "false" to prevent default', t => { const maintenance = [{name: '1.x', channel: false, tags: []}]; - const release = [{name: 'master', channel: false, tags: []}, {name: 'next', channel: false, tags: []}]; + const release = [ + {name: 'master', channel: false, tags: []}, + {name: 'next', channel: false, tags: []}, + ]; const prerelease = [{name: 'beta', channel: false, prerelease: true, tags: []}]; - t.deepEqual(normalize.maintenance({maintenance, release}).map(({name, channel}) => ({name, channel})), [ - {name: '1.x', channel: false}, - ]); - t.deepEqual(normalize.release({release}).map(({name, channel}) => ({name, channel})), [ - {name: 'master', channel: false}, - {name: 'next', channel: false}, - ]); - t.deepEqual(normalize.prerelease({prerelease}).map(({name, channel}) => ({name, channel})), [ - {name: 'beta', channel: false}, - ]); + t.deepEqual( + normalize.maintenance({maintenance, release}).map(({name, channel}) => ({name, channel})), + [{name: '1.x', channel: false}] + ); + t.deepEqual( + normalize.release({release}).map(({name, channel}) => ({name, channel})), + [ + {name: 'master', channel: false}, + {name: 'next', channel: false}, + ] + ); + t.deepEqual( + normalize.prerelease({prerelease}).map(({name, channel}) => ({name, channel})), + [{name: 'beta', channel: false}] + ); }); diff --git a/test/get-releases-to-add.test.js b/test/get-releases-to-add.test.js index 7e6b0357..e7fdb32f 100644 --- a/test/get-releases-to-add.test.js +++ b/test/get-releases-to-add.test.js @@ -268,7 +268,10 @@ test('Exclude versions merged from release to maintenance branch if they have th {gitTag: 'v1.1.0', version: '1.1.0'}, ], }, - branches: [{name: '2.x', channel: 'latest'}, {name: 'master', channel: 'latest'}], + branches: [ + {name: '2.x', channel: 'latest'}, + {name: 'master', channel: 'latest'}, + ], options: {tagFormat: `v\${version}`}, }); @@ -308,7 +311,11 @@ test('Exclude versions merged between release branches if they all have "channel {gitTag: 'v2.0.0', version: '2.0.0'}, ], }, - branches: [{name: 'master', channel: false}, {name: 'next', channel: false}, {name: 'next-major', channel: false}], + branches: [ + {name: 'master', channel: false}, + {name: 'next', channel: false}, + {name: 'next-major', channel: false}, + ], options: {tagFormat: `v\${version}`}, }); diff --git a/test/helpers/git-utils.js b/test/helpers/git-utils.js index 2019d561..0473bb3d 100644 --- a/test/helpers/git-utils.js +++ b/test/helpers/git-utils.js @@ -86,9 +86,11 @@ export async function gitCommits(messages, execaOpts) { */ export async function gitGetCommits(from, execaOpts) { Object.assign(gitLogParser.fields, {hash: 'H', message: 'B', gitTags: 'd', committerDate: {key: 'ci', type: Date}}); - return (await getStream.array( - gitLogParser.parse({_: `${from ? from + '..' : ''}HEAD`}, {...execaOpts, env: {...process.env, ...execaOpts.env}}) - )).map(commit => { + return ( + await getStream.array( + gitLogParser.parse({_: `${from ? from + '..' : ''}HEAD`}, {...execaOpts, env: {...process.env, ...execaOpts.env}}) + ) + ).map(commit => { commit.message = commit.message.trim(); commit.gitTags = commit.gitTags.trim(); return commit; diff --git a/test/plugins/pipeline.test.js b/test/plugins/pipeline.test.js index 6c58129e..d3f6e434 100644 --- a/test/plugins/pipeline.test.js +++ b/test/plugins/pipeline.test.js @@ -47,7 +47,12 @@ test('Execute each function in series passing the "lastResult" and "result" to " const result = await pipeline([step1, step2, step3, step4], {settleAll: false, getNextInput})(5); t.deepEqual(result, [1, 2, 3, 4]); - t.deepEqual(getNextInput.args, [[5, 1], [5, 2], [5, 3], [5, 4]]); + t.deepEqual(getNextInput.args, [ + [5, 1], + [5, 2], + [5, 3], + [5, 4], + ]); }); test('Execute each function in series calling "transform" to modify the results', async t => { @@ -61,7 +66,12 @@ test('Execute each function in series calling "transform" to modify the results' const result = await pipeline([step1, step2, step3, step4], {getNextInput, transform})(5); t.deepEqual(result, [1 + 1, 2 + 1, 3 + 1, 4 + 1]); - t.deepEqual(getNextInput.args, [[5, 1 + 1], [5, 2 + 1], [5, 3 + 1], [5, 4 + 1]]); + t.deepEqual(getNextInput.args, [ + [5, 1 + 1], + [5, 2 + 1], + [5, 3 + 1], + [5, 4 + 1], + ]); }); test('Execute each function in series calling "transform" to modify the results with "settleAll"', async t => { @@ -75,7 +85,12 @@ test('Execute each function in series calling "transform" to modify the results const result = await pipeline([step1, step2, step3, step4], {settleAll: true, getNextInput, transform})(5); t.deepEqual(result, [1 + 1, 2 + 1, 3 + 1, 4 + 1]); - t.deepEqual(getNextInput.args, [[5, 1 + 1], [5, 2 + 1], [5, 3 + 1], [5, 4 + 1]]); + t.deepEqual(getNextInput.args, [ + [5, 1 + 1], + [5, 2 + 1], + [5, 3 + 1], + [5, 4 + 1], + ]); }); test('Stop execution and throw error if a step rejects', async t => {