From 0738dd649141a8372f89aa4513bf4512b8465617 Mon Sep 17 00:00:00 2001 From: Chauncey McAskill Date: Tue, 29 Mar 2022 21:06:34 -0400 Subject: [PATCH] Improve glob.js Added constant `supportsGlob` to provide a boolean to check if a glob function is available. --- build/tasks/concats.js | 6 +++--- build/utils/glob.js | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build/tasks/concats.js b/build/tasks/concats.js index c4d44fc..f7790e2 100644 --- a/build/tasks/concats.js +++ b/build/tasks/concats.js @@ -1,5 +1,5 @@ import loconfig from '../utils/config.js'; -import glob from '../utils/glob.js'; +import glob, { supportsGlob } from '../utils/glob.js'; import message from '../utils/message.js'; import notification from '../utils/notification.js'; import resolve from '../utils/template.js'; @@ -64,7 +64,7 @@ export const productionConcatFilesArgs = [ * @return {Promise} */ export default async function concatFiles(globOptions = null, concatOptions = null) { - if (glob) { + if (supportsGlob) { if (globOptions == null) { globOptions = productionGlobOptions; } else if ( @@ -105,7 +105,7 @@ export default async function concatFiles(globOptions = null, concatOptions = nu includes = resolve(includes); outfile = resolve(outfile); - if (glob && globOptions) { + if (supportsGlob && globOptions) { includes = await glob(includes, globOptions); } diff --git a/build/utils/glob.js b/build/utils/glob.js index 13cb6f1..1f916c2 100644 --- a/build/utils/glob.js +++ b/build/utils/glob.js @@ -31,6 +31,8 @@ try { // do nothing } +export const supportsGlob = (typeof glob === 'function'); + export default glob; /**