How to use is-glob - 10 common examples

To help you get started, we’ve selected a few is-glob examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ionic-team / stencil / src / compiler / copy / config-copy-tasks.ts View on Github external
export async function processCopyTasks(_config: d.Config, _allCopyTasks: d.CopyTask[], copyTask: d.CopyTask): Promise {
  if (!copyTask) {
    // possible null was set, which is fine, just skip over this one
    return;
  }

  if (!copyTask.src) {
    throw new Error(`copy missing "src" property`);
  }

  if (copyTask.dest && isGlob(copyTask.dest)) {
    throw new Error(`copy "dest" property cannot be a glob: ${copyTask.dest}`);
  }

  // const outputTargets = config.outputTargets.filter(isOutputTargetBuild);

  // if (isGlob(copyTask.src)) {
  //   const copyTasks = await processGlob(config, outputTargets, copyTask);
  //   allCopyTasks.push(...copyTasks);
  //   return;
  // }

  // await Promise.all(outputTargets.map(async outputTarget => {
  //   await processCopyTaskDestDir(config, allCopyTasks, copyTask, outputTarget.dir);
  // }));
}
github DevExpress / testcafe / src / utils / parse-file-list.js View on Github external
fileList = await Promise.all(fileList.map(async file => {
        if (!isGlob(file)) {
            const absPath = path.resolve(baseDir, file);
            let fileStat  = null;

            try {
                fileStat = await stat(absPath);
            }
            catch (err) {
                return null;
            }

            if (fileStat.isDirectory())
                return path.join(file, TEST_FILE_GLOB_PATTERN);

            if (OS.win)
                file = modifyFileRoot(baseDir, file);
        }
github ardatan / graphql-toolkit / packages / common / src / helpers.ts View on Github external
export function isValidPath(str: string): boolean {
  return typeof str === 'string' && !isGlob(str) && !invalidPathRegex.test(str);
}
github andersonba / github-review-filter / src / filter.js View on Github external
searchFiles(search) {
    const matches = isGlob(search)
      ? minimatch.match(this.fileTexts, search, {
        matchBase: true,
        nocase: true,
        dot: true,
      })
      : this.fileTexts.filter(t => t.includes(search));

    let total = 0;
    this.files.forEach(({ text, element }) => {
      const matched = matches.includes(text);
      element.style.display = matched ? 'block' : 'none';
      if (matched) {
        total += 1;
      }
    });
    this.total = total;
github teambit / bit / src / utils / getMissingTestFiles.js View on Github external
const realTestFiles = tests.filter((testFile) => {
    const files = DSL.filter(pattern => testFile.indexOf(pattern) > -1);
    const glob = isGlob(pathNormalizeToLinux(testFile));
    return !glob && R.isEmpty(files) ? testFile : undefined;
  });
  if (!R.isEmpty(realTestFiles)) {
github zinserjan / mocha-webpack / src / cli / prepareWebpack.js View on Github external
function directoryToGlob(directory, options) {
  const { recursive, glob } = options;

  let fileGlob = defaultFilePattern;

  if (glob) {
    if (!isGlob(glob)) {
      throw new Error(`Provided Glob ${glob} is not a valid glob pattern`);
    }

    const parent = globParent(glob);

    if (parent !== '.' || glob.indexOf('**') !== -1) {
      throw new Error(`Provided Glob ${glob} must be a file pattern like *.js`);
    }

    fileGlob = glob;
  }


  const normalizedPath = normalizePath(directory);
  const globstar = recursive ? '**/' : '';
  const filePattern = [globstar, fileGlob].join('');
github steelbrain / ucompiler / src / helpers / get-rules.js View on Github external
config.rules.forEach(function(rule) {
    const matches = isGlob(rule.path) ? isMatch(relativePath, rule.path) : relativePath === rule.path
    if (matches) {
      for (const key in rule) {
        if (typeof localConfig[key] !== 'undefined' && localConfig[key] instanceof Array) {
          localConfig[key] = localConfig[key].concat(rule[key])
        } else {
          localConfig[key] = rule[key]
        }
      }
    }
  })
github beemojs / beemo / packages / core / src / routines / driver / ExecuteCommandRoutine.ts View on Github external
argv.forEach(arg => {
      if (arg.charAt(0) !== '-' && isGlob(arg)) {
        const paths = glob
          .sync(arg, {
            cwd: String(context.cwd),
            onlyDirectories: false,
            onlyFiles: false,
          })
          .map(path => new Path(path).path());

        this.debug(
          '  %s %s %s',
          arg,
          chalk.gray('->'),
          paths.length > 0 ? paths.join(', ') : chalk.gray(this.tool.msg('app:noMatch')),
        );

        nextArgv.push(...paths);
github episodeyang / ml_logger / ml-dash-client / src / pages / Dash / ExperimentDash.js View on Github external
function matchKeys(k, patterns) {
    //todo: factor out the glob ones, use two list for matching.
    if (patterns.indexOf(k))
      return true;
    for (let p of patterns) {
      if (isGlob(p) && minimatch(k, p))
        return true
    }
    return false;
  }
github zinserjan / mocha-webpack / src / util / glob.js View on Github external
export const ensureGlob = (entry: string, recursive: boolean = false, pattern: string = '*.js'): string => {
  const normalized = normalizePath(entry);

  if (isGlob(normalized)) {
    return normalized;
  } else if (isDirectory(normalized)) {
    if (!isGlob(pattern)) {
      throw new Error(`Provided Glob ${pattern} is not a valid glob pattern`);
    }

    const parent = globParent(pattern);
    if (parent !== '.' || pattern.indexOf('**') !== -1) {
      throw new Error(`Provided Glob ${pattern} must be a file pattern like *.js`);
    }

    const globstar = recursive ? '**/' : '';

    return `${normalized}/${globstar}${pattern}`;
  }
  return normalized;
};

is-glob

Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a bet

MIT
Latest version published 2 years ago

Package Health Score

74 / 100
Full package analysis

Popular is-glob functions