From c9de95f4d82a8a2b963e395370fd081a0fcb4caa Mon Sep 17 00:00:00 2001 From: Yasuaki Uechi Date: Tue, 15 Oct 2019 21:38:58 +0900 Subject: [PATCH] fix: use releases instead of release --- .../src/lib/config/defaultConfig.js | 2 +- .../src/step/release/createGitHubRelease.js | 23 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/shipjs-lib/src/lib/config/defaultConfig.js b/packages/shipjs-lib/src/lib/config/defaultConfig.js index 944975f0..1f3715d4 100644 --- a/packages/shipjs-lib/src/lib/config/defaultConfig.js +++ b/packages/shipjs-lib/src/lib/config/defaultConfig.js @@ -183,7 +183,7 @@ export default { ], }), }, - release: { + releases: { assetsToUpload: [], }, }; diff --git a/packages/shipjs/src/step/release/createGitHubRelease.js b/packages/shipjs/src/step/release/createGitHubRelease.js index 3f933a72..7b06bf73 100644 --- a/packages/shipjs/src/step/release/createGitHubRelease.js +++ b/packages/shipjs/src/step/release/createGitHubRelease.js @@ -30,7 +30,7 @@ export default async ({ version, config, dir, dryRun }) => await runStep( { title: 'Creating a release on GitHub repository' }, async ({ run }) => { - const { getTagName, release } = config; + const { getTagName, releases } = config; const tagName = getTagName({ version }); const args = []; @@ -42,24 +42,27 @@ export default async ({ version, config, dir, dryRun }) => args.push(`-F ${exportedPath}`); // handle assets - if (release && release.assetsToUpload) { - const option = release.assetsToUpload; + if (releases && releases.assetsToUpload) { + const option = releases.assetsToUpload; const assetPaths = []; - if (Array.isArray(option) && option.length > 0) { - // list - for (const asset of option) { - const files = await globby(asset); - assetPaths.push(...files); - } - } else if (typeof option === 'function') { + if (typeof option === 'function') { // function + // assetsToUpload: ({dir, version, tagName}) => [...] const files = await Promise.resolve( option({ dir, version, tagName }) ); assetPaths.push(...files); + } else if (Array.isArray(option) && option.length > 0) { + // list + // assetsToUpload: ['package.json', 'dist/*.zip'] + for (const asset of option) { + const files = await globby(asset); + assetPaths.push(...files); + } } else if (typeof option === 'string') { // string + // assetsToUpload: 'archive.zip' assetPaths.push(option); }