Make glob optional in concats.js
Added: - Condition to process includes with glob if it's available. Changed: - Utility 'glob.js' to not throw an error if a glob function is unavailable.
This commit is contained in:
@@ -56,20 +56,24 @@ export const productionConcatFilesArgs = [
|
|||||||
* @todo Add support for minification.
|
* @todo Add support for minification.
|
||||||
*
|
*
|
||||||
* @async
|
* @async
|
||||||
* @param {object} [globOptions=null] - Customize the glob options.
|
* @param {object|boolean} [globOptions=null] - Customize the glob options.
|
||||||
* If `null`, default production options are used.
|
* If `null`, default production options are used.
|
||||||
* @param {object} [concatOptions=null] - Customize the concatenation options.
|
* If `false`, the glob function will be ignored.
|
||||||
|
* @param {object} [concatOptions=null] - Customize the concatenation options.
|
||||||
* If `null`, default production options are used.
|
* If `null`, default production options are used.
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
export default async function concatFiles(globOptions = null, concatOptions = null) {
|
export default async function concatFiles(globOptions = null, concatOptions = null) {
|
||||||
if (globOptions == null) {
|
if (glob) {
|
||||||
globOptions = productionGlobOptions;
|
if (globOptions == null) {
|
||||||
} else if (
|
globOptions = productionGlobOptions;
|
||||||
globOptions !== developmentGlobOptions &&
|
} else if (
|
||||||
globOptions !== productionGlobOptions
|
globOptions !== false &&
|
||||||
) {
|
globOptions !== developmentGlobOptions &&
|
||||||
globOptions = Object.assign({}, defaultGlobOptions, globOptions);
|
globOptions !== productionGlobOptions
|
||||||
|
) {
|
||||||
|
globOptions = Object.assign({}, defaultGlobOptions, globOptions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (concatOptions == null) {
|
if (concatOptions == null) {
|
||||||
@@ -97,7 +101,13 @@ export default async function concatFiles(globOptions = null, concatOptions = nu
|
|||||||
includes = includes.map((path) => template(path));
|
includes = includes.map((path) => template(path));
|
||||||
outfile = template(outfile);
|
outfile = template(outfile);
|
||||||
|
|
||||||
let files = await glob(includes, globOptions);
|
let files;
|
||||||
|
|
||||||
|
if (glob && globOptions) {
|
||||||
|
files = await glob(includes, globOptions);
|
||||||
|
} else {
|
||||||
|
files = includes;
|
||||||
|
}
|
||||||
|
|
||||||
if (concatOptions.removeDuplicates) {
|
if (concatOptions.removeDuplicates) {
|
||||||
files = files.map((path) => normalize(path));
|
files = files.map((path) => normalize(path));
|
||||||
|
|||||||
@@ -22,7 +22,15 @@ const candidates = [
|
|||||||
'glob',
|
'glob',
|
||||||
];
|
];
|
||||||
|
|
||||||
export default await importGlob();
|
let glob;
|
||||||
|
|
||||||
|
try {
|
||||||
|
glob = await importGlob();
|
||||||
|
} catch (err) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
export default glob;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Imports the first available glob function.
|
* Imports the first available glob function.
|
||||||
|
|||||||
Reference in New Issue
Block a user