Improve syntax of glob.js
Changed: - Renamed variables for clarity. Fixed: - Block comment for `createArrayableGlob()`.
This commit is contained in:
@@ -12,19 +12,19 @@
|
|||||||
|
|
||||||
import { promisify } from 'node:util';
|
import { promisify } from 'node:util';
|
||||||
|
|
||||||
const modules = [
|
const candidates = [
|
||||||
'tiny-glob',
|
'tiny-glob',
|
||||||
'globby',
|
'globby',
|
||||||
'fast-glob',
|
'fast-glob',
|
||||||
'glob',
|
'glob',
|
||||||
];
|
];
|
||||||
|
|
||||||
var glob;
|
var glob, module;
|
||||||
|
|
||||||
for (let name of modules) {
|
for (let name of candidates) {
|
||||||
try {
|
try {
|
||||||
glob = await import(name);
|
module = await import(name);
|
||||||
glob = glob.default;
|
module = module.default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap the function to ensure
|
* Wrap the function to ensure
|
||||||
@@ -32,13 +32,17 @@ for (let name of modules) {
|
|||||||
*/
|
*/
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case 'tiny-glob':
|
case 'tiny-glob':
|
||||||
glob = createArrayableGlob(glob, {
|
glob = createArrayableGlob(module, {
|
||||||
filesOnly: true
|
filesOnly: true
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'glob':
|
case 'glob':
|
||||||
glob = promisify(glob);
|
glob = promisify(module);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
glob = module;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +66,7 @@ export default glob;
|
|||||||
*
|
*
|
||||||
* @param {function} glob - The glob function.
|
* @param {function} glob - The glob function.
|
||||||
* @param {object} options - The glob options.
|
* @param {object} options - The glob options.
|
||||||
* @return {Promise}
|
* @return {function}
|
||||||
*/
|
*/
|
||||||
function createArrayableGlob(glob, options) {
|
function createArrayableGlob(glob, options) {
|
||||||
return (patterns, options) => {
|
return (patterns, options) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user