8000 fix: fix globbed asset sorting and deduping · coderbyheart/github@83444bf · GitHub
[go: up one dir, main page]

Skip to content

Commit 83444bf

Browse files
committed
fix: fix globbed asset sorting and deduping
1 parent 4748c8a commit 83444bf

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

lib/glob-assets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ module.exports = async ({cwd}, assets) =>
6565
// Sort with Object first, to prioritize Object definition over Strings in dedup
6666
))
6767
)
68-
.sort(asset => !isPlainObject(asset)),
68+
.sort(asset => (isPlainObject(asset) ? -1 : 1)),
6969
// Compare `path` property if Object definition, value itself if String
7070
(a, b) => path.resolve(cwd, isPlainObject(a) ? a.path : a) === path.resolve(cwd, isPlainObject(b) ? b.path : b)
7171
);

test/integration.test.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,8 @@ test.serial('Publish a release with an array of assets', async t => {
131131
const repo = 'test_repo';
132132
const env = {GITHUB_TOKEN: 'github_token'};
133133
const assets = [
134-
'upload.txt',
135-
{path: ['*.txt', '!**/*_other.txt'], name: 'upload_file_name.txt'},
136-
{path: ['*.txt'], name: 'other_file.txt', label: 'Other File'},
134+
{path: ['upload.txt'], name: 'upload_file_name.txt'},
135+
{path: ['upload_other.txt'], name: 'other_file.txt', label: 'Other File'},
137136
];
138137
const nextRelease = {version: '1.0.0', gitHead: '123', gitTag: 'v1.0.0', notes: 'Test release note body'};
139138
const options = {branch: 'master', repositoryUrl: `https://github.com/${owner}/${repo}.git`};
@@ -163,7 +162,7 @@ test.serial('Publish a release with an array of assets', async t => {
163162
uploadUrl: 'https://github.com',
164163
contentLength: (await stat(path.resolve(cwd, 'upload_other.txt'))).size,
165164
})
166-
.post(`${uploadUri}?name=${escape('upload_other.txt')}&label=${escape('Other File')}`)
165+
.post(`${uploadUri}?name=${escape('other_file.txt')}&label=${escape('Other File')}`)
167166
.reply(200, {browser_download_url: otherAssetUrl});
168167

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

0 commit comments

Comments
 (0)
0