Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): migrate globby to tinyglobby #938

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions lib/glob-assets.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { basename, resolve } from "node:path";

import { isPlainObject, castArray, uniqWith, uniq } from "lodash-es";
import dirGlob from "dir-glob";
import { globby } from "globby";
import debugFactory from "debug";
import dirGlob from "dir-glob";
import { isPlainObject, castArray, uniqWith, uniq } from "lodash-es";
import { glob as tg } from "tinyglobby";

const debug = debugFactory("semantic-release:github");

Expand All @@ -22,17 +22,20 @@ export default async function globAssets({ cwd }, assets) {
if (glob.length <= 1 && glob[0].startsWith("!")) {
debug(
"skipping the negated glob %o as its alone in its group and would retrieve a large amount of files",
glob[0],
glob[0]
);
return [];
}

const globbed = await globby(glob, {
cwd,
expandDirectories: false, // TODO Temporary workaround for https://github.com/mrmlnc/fast-glob/issues/47
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue doesn't happen with tinyglobby, so we don't need to disable expanding directories.

dot: true,
onlyFiles: false,
});
const globbed = (
await tg(glob, {
cwd,
dot: true,
onlyFiles: false,
})
).map((result) =>
result.endsWith("/") ? result.slice(0, -1) : result
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stems from the way tinyglobby returns the results:
366205111-4bfd55b6-014d-4781-b7d8-fbe6776228b4

In case returning a trailing slash wouldn't break users, and you decide to go forward with this migration, I'm open to updating the tests instead!

);

if (isPlainObject(asset)) {
if (globbed.length > 1) {
Expand Down Expand Up @@ -61,7 +64,7 @@ export default async function globAssets({ cwd }, assets) {

// If asset is a String definition but no match is found, output the elements of the original glob (each one will be considered as a missing file)
return glob;
}),
})
// Sort with Object first, to prioritize Object definition over Strings in dedup
)
)
Expand All @@ -70,6 +73,6 @@ export default async function globAssets({ cwd }, assets) {
// Compare `path` property if Object definition, value itself if String
(a, b) =>
resolve(cwd, isPlainObject(a) ? a.path : a) ===
resolve(cwd, isPlainObject(b) ? b.path : b),
resolve(cwd, isPlainObject(b) ? b.path : b)
);
}
64 changes: 62 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
"aggregate-error": "^5.0.0",
"debug": "^4.3.4",
"dir-glob": "^3.0.1",
"globby": "^14.0.0",
"http-proxy-agent": "^7.0.0",
"https-proxy-agent": "^7.0.0",
"issue-parser": "^7.0.0",
"lodash-es": "^4.17.21",
"mime": "^4.0.0",
"p-filter": "^4.0.0",
"tinyglobby": "^0.2.9",
"url-join": "^5.0.0"
},
"devDependencies": {
Expand Down