Skip to content

Commit

Permalink
fix: deduplicate glob results by resolved path
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg committed Aug 26, 2018
1 parent 2090a90 commit 704ac79
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/glob-assets.js
Expand Up @@ -67,5 +67,5 @@ module.exports = async ({cwd}, assets) =>
)
.sort(asset => !isPlainObject(asset)),
// Compare `path` property if Object definition, value itself if String
(a, b) => (isPlainObject(a) ? a.path : a) === (isPlainObject(b) ? b.path : b)
(a, b) => path.resolve(cwd, isPlainObject(a) ? a.path : a) === path.resolve(cwd, isPlainObject(b) ? b.path : b)
);
8 changes: 8 additions & 0 deletions test/glob-assets.test.js
Expand Up @@ -183,3 +183,11 @@ test('Include empty directory as defined', async t => {

t.deepEqual(globbedAssets, ['empty']);
});

test('Deduplicate resulting files path', async t => {
const cwd = tempy.directory();
await copy(fixtures, cwd);
const globbedAssets = await globAssets({cwd}, ['./upload.txt', path.resolve(cwd, 'upload.txt'), 'upload.txt']);

t.deepEqual(globbedAssets, ['upload.txt']);
});

0 comments on commit 704ac79

Please sign in to comment.