All files / src/fs/util glob-util.js

100% Statements 20/20
100% Branches 8/8
100% Functions 7/7
100% Lines 17/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 321x 1x 1x   1x   1x 8x     1x 385x     1x 51x     91x 51x 381x 236x   236x 71x       310x      
import minimatch from 'minimatch';
import capture from 'minimatch-capture';
import { List } from 'immutable';
 
const GLOB_OPTIONS = {dot: true};
 
export const glob = (str, globPattern) => {
  return minimatch(str, globPattern, GLOB_OPTIONS);
};
 
export const globSeq = (seq, globPattern) => {
  return seq.filter((path) => minimatch(path, globPattern, GLOB_OPTIONS));
};
 
export const globPaths = (fs, globPattern) => {
  return globSeq(fs.keySeq(), globPattern);
};
 
export const captureGlobPaths = (fs, globPattern, filterCondition = (path) => true) => {
  return fs.keySeq().reduce((captures, path) => {
    if (filterCondition(path)) {
      const pathCaptures = capture(path, globPattern, GLOB_OPTIONS);
 
      if (pathCaptures) {
        return captures.concat(pathCaptures);
      }
    }
 
    return captures;
  }, List());
};