feat: init
This commit is contained in:
34
node_modules/replace-in-file/lib/helpers/glob-async.js
generated
vendored
Normal file
34
node_modules/replace-in-file/lib/helpers/glob-async.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Dependencies
|
||||
*/
|
||||
const glob = require('glob');
|
||||
|
||||
/**
|
||||
* Async wrapper for glob
|
||||
*/
|
||||
module.exports = function globAsync(pattern, ignore, allowEmptyPaths, cfg) {
|
||||
|
||||
//Prepare glob config
|
||||
cfg = Object.assign({ignore}, cfg, {nodir: true});
|
||||
|
||||
//Return promise
|
||||
return new Promise((resolve, reject) => {
|
||||
glob(pattern, cfg, (error, files) => {
|
||||
|
||||
//istanbul ignore if: hard to make glob error
|
||||
if (error) {
|
||||
return reject(error);
|
||||
}
|
||||
|
||||
//Error if no files match, unless allowed
|
||||
if (!allowEmptyPaths && files.length === 0) {
|
||||
return reject(new Error('No files match the pattern: ' + pattern));
|
||||
}
|
||||
|
||||
//Resolve
|
||||
resolve(files);
|
||||
});
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user