feat: init
This commit is contained in:
42
node_modules/replace-in-file/lib/helpers/get-paths-sync.js
generated
vendored
Normal file
42
node_modules/replace-in-file/lib/helpers/get-paths-sync.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Dependencies
|
||||
*/
|
||||
const glob = require('glob');
|
||||
|
||||
/**
|
||||
* Get paths (sync)
|
||||
*/
|
||||
module.exports = function getPathsSync(patterns, config) {
|
||||
|
||||
//Extract relevant config
|
||||
const {ignore, disableGlobs, glob: globConfig, cwd} = config;
|
||||
|
||||
//Not using globs?
|
||||
if (disableGlobs) {
|
||||
return patterns;
|
||||
}
|
||||
|
||||
//Prepare glob config
|
||||
const cfg = Object.assign({ignore}, globConfig, {nodir: true});
|
||||
|
||||
//Append CWD configuration if given (#56)
|
||||
//istanbul ignore if
|
||||
if (cwd) {
|
||||
cfg.cwd = cwd;
|
||||
}
|
||||
|
||||
//Get paths
|
||||
const paths = patterns.map(pattern => glob.sync(pattern, cfg));
|
||||
const flattened = [].concat.apply([], paths);
|
||||
|
||||
//Prefix each path with CWD if given (#56)
|
||||
//istanbul ignore if
|
||||
if (cwd) {
|
||||
return flattened.map(path => `${cwd}${path}`);
|
||||
}
|
||||
|
||||
//Return flattened
|
||||
return flattened;
|
||||
};
|
||||
Reference in New Issue
Block a user