Skip to content

Commit

Permalink
fix: fix globbed asset sorting and deduping
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg committed Oct 26, 2018
1 parent 4748c8a commit 83444bf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/glob-assets.js
Expand Up @@ -65,7 +65,7 @@ module.exports = async ({cwd}, assets) =>
// Sort with Object first, to prioritize Object definition over Strings in dedup
))
)
.sort(asset => !isPlainObject(asset)),
.sort(asset => (isPlainObject(asset) ? -1 : 1)),
// Compare `path` property if Object definition, value itself if String
(a, b) => path.resolve(cwd, isPlainObject(a) ? a.path : a) === path.resolve(cwd, isPlainObject(b) ? b.path : b)
);
7 changes: 3 additions & 4 deletions test/integration.test.js
Expand Up @@ -131,9 +131,8 @@ test.serial('Publish a release with an array of assets', async t => {
const repo = 'test_repo';
const env = {GITHUB_TOKEN: 'github_token'};
const assets = [
'upload.txt',
{path: ['*.txt', '!**/*_other.txt'], name: 'upload_file_name.txt'},
{path: ['*.txt'], name: 'other_file.txt', label: 'Other File'},
{path: ['upload.txt'], name: 'upload_file_name.txt'},
{path: ['upload_other.txt'], name: 'other_file.txt', label: 'Other File'},
];
const nextRelease = {version: '1.0.0', gitHead: '123', gitTag: 'v1.0.0', notes: 'Test release note body'};
const options = {branch: 'master', repositoryUrl: `https://github.com/${owner}/${repo}.git`};
Expand Down Expand Up @@ -163,7 +162,7 @@ test.serial('Publish a release with an array of assets', async t => {
uploadUrl: 'https://github.com',
contentLength: (await stat(path.resolve(cwd, 'upload_other.txt'))).size,
})
.post(`${uploadUri}?name=${escape('upload_other.txt')}&label=${escape('Other File')}`)
.post(`${uploadUri}?name=${escape('other_file.txt')}&label=${escape('Other File')}`)
.reply(200, {browser_download_url: otherAssetUrl});

const result = await t.context.m.publish({assets}, {cwd, env, options, nextRelease, logger: t.context.logger});
Expand Down

0 comments on commit 83444bf

Please sign in to comment.