Skip to content

Commit

Permalink
chore: swap to tinyglobby
Browse files Browse the repository at this point in the history
  • Loading branch information
lishaduck committed Oct 30, 2024
1 parent d613afb commit ec58e9f
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 65 deletions.
18 changes: 9 additions & 9 deletions lib/extra-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ const OsHelpers = require('./os-helpers');
* @import {ExtraFileRequest, NonElmFiles} from "./types/content"
*/

// microsoft/TypeScript#58955
/** @typedef {import("globby", {with: {'resolution-mode': 'import'}}).globby} globby */
/**
* @import {glob} from "tinyglobby"
*/

/**
* Collect the extra files requested by the rules.
Expand All @@ -15,9 +16,9 @@ const OsHelpers = require('./os-helpers');
* @returns {Promise<NonElmFiles>}
*/
async function collect(requests) {
const {globby} = await import('globby');
const {glob} = await import('tinyglobby');
const files2D = await Promise.all(
requests.map((request) => getFiles(globby, request))
requests.map((request) => getFiles(glob, request))
);
const flatFiles = files2D.flat();
const files = unique(flatFiles);
Expand All @@ -38,12 +39,12 @@ async function collect(requests) {
}

/**
* @param {globby} globby
* @param {typeof glob} glob
* @param {ExtraFileRequest} request
* @returns {Promise<string[]>}
*/
function getFiles(globby, request) {
return globby(
function getFiles(glob, request) {
return glob(
request.files.map(
(file) =>
`${file.included ? '' : '!'}${OsHelpers.makePathOsAgnostic(
Expand All @@ -56,8 +57,7 @@ function getFiles(globby, request) {
expandDirectories: false,
caseSensitiveMatch: true,
onlyFiles: true,
dot: true,
extglob: false
dot: true
}
);
}
Expand Down
Loading

0 comments on commit ec58e9f

Please sign in to comment.