How to use the globby.hasMagic function in globby

To help you get started, we’ve selected a few globby 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 JS-DevTools / globify / lib / parsed-args.js View on Github external
function parseGlobs (args, parsed) {
  let patterns = [];

  if (parsed.globIndex === -1 && globby.hasMagic(args[0])) {
    while (args[0] && args[0][0] !== "-") {
      // We found an entry file glob pattern
      let pattern = args.shift();
      patterns.push(pattern);

      // Set the baseDir, if not already set
      parsed.baseDir = parsed.baseDir || helpers.getBaseDir(pattern);
    }

    if (patterns.length) {
      // We found entry file(s), so set the glob index and create the glob function
      parsed.globIndex = parsed.args.length;
      parsed.args.push((options) => {
        return globby.sync(patterns, options);
      });
    }
github JS-DevTools / version-bump-prompt / src / normalize-options.ts View on Github external
async function strictGlobMatch(file: string, options: object): Promise {
  let matches = await globby(file, options);

  if (matches.length === 0) {
    if (hasMagic(file)) {
      throw new Error(`Could not find any files matching "${file}".`);
    }
    else {
      throw new Error(`Could not find file: ${file}.`);
    }
  }

  // Return files in a predictable order
  return matches.sort();
}
github clippedjs / clipped / plugins / rollup / clipped.config.js View on Github external
cfg.plugins.use('autoinstall', require('@rollup/plugin-auto-install'), [{}])
      }

      // if (['umd', 'iife'].includes(cfg.output.format)) {
        cfg.plugins
          .use('node-resolve', require('rollup-plugin-node-resolve'), [{
            main: false,
            module: true,
            jsnext: true,
            extensions: ['.js', '.json'],
            preferBuiltIns: true,
            browser: true
          }])
      // }

      if (globby.hasMagic(cfg.input)) {
        cfg.plugins.use('multi-entry', require('rollup-plugin-multi-entry'), [])
      }
    }
  },
github bentonam / fakeit / app / utils.js View on Github external
items = sort(await map(items, (item) => {
      if (globby.hasMagic(item)) {
        return globby(item);
      } else if (!!path.extname(item)) {
        return item;
      }

      return globby(path.join(item, '*'));
    }));
    if (items.length) {
github marp-team / marp-cli / src / theme.ts View on Github external
static async initialize(baseFn: string[], themes: Theme[] = []) {
    const fn = [...baseFn, ...themes.map(t => t.filename)]
    const found = await ThemeSet.findPath(fn)
    const fnForWatch: Set = new Set(found.map(f => path.resolve(f)))

    for (const f of fn) {
      if (!hasMagic(f)) {
        try {
          const stat: fs.Stats = await lstat(f)

          if (stat.isFile() || stat.isDirectory() || stat.isSymbolicLink())
            fnForWatch.add(path.resolve(f))
        } catch (e) {}
      }
    }

    const instance = new ThemeSet({ fn, fnForWatch: [...fnForWatch] })
    for (const f of found) await instance.load(f)

    themes.forEach(t => instance.add(t))

    return instance
  }
github jhotmann / node-rename-cli / rename.js View on Github external
function getFileArray(files) {
  files = files.map(f => {
    return f.replace(/\[/g, '\\[').replace(/\]/g, '\\]');
  });
  if (globby.hasMagic(files)) {
    files = globby.sync(files);
  }
  return files;
}
github codemod-js / codemod / packages / cli / src / Options.ts View on Github external
case '--help':
          return { kind: 'help' };

        case '--version':
          return { kind: 'version' };

        case '-d':
        case '--dry':
          config.dry(true);
          break;

        default:
          if (arg[0] === '-') {
            throw new Error(`unexpected option: ${arg}`);
          } else {
            if (hasGlob(arg)) {
              config.addSourcePaths(...globSync(arg));
            } else {
              config.addSourcePath(arg);
            }
          }
          break;
      }
    }

    return {
      kind: 'run',
      config: config.build()
    };
  }
}
github stylelint / stylelint / lib / printConfig.js View on Github external
const configFile = options.configFile;
	const configOverrides = options.configOverrides;
	const globbyOptions = options.globbyOptions;
	const files = options.files;

	const isCodeNotFile = code !== undefined;

	if (!files || files.length !== 1 || isCodeNotFile) {
		return Promise.reject(
			new Error('The --print-config option must be used with exactly one file path.'),
		);
	}

	const filePath = files[0];

	if (globby.hasMagic(filePath)) {
		return Promise.reject(new Error('The --print-config option does not support globs.'));
	}

	const stylelint = createStylelint({
		config,
		configFile,
		configBasedir,
		configOverrides,
	});

	const cwd = _.get(globbyOptions, 'cwd', process.cwd());
	const absoluteFilePath = !path.isAbsolute(filePath)
		? path.join(cwd, filePath)
		: path.normalize(filePath);

	const configSearchPath = stylelint._options.configFile || absoluteFilePath;
github SimenB / add-asset-html-webpack-plugin / src / utils.js View on Github external
assets.forEach(asset =>
    asset.filepath && globby.hasMagic(asset.filepath)
      ? globbyAssets.push(asset)
      : normalAssets.push(asset),
  );

globby

User-friendly glob matching

MIT
Latest version published 3 months ago

Package Health Score

86 / 100
Full package analysis