How to use the @parcel/utils.glob function in @parcel/utils

To help you get started, we’ve selected a few @parcel/utils 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 parcel-bundler / parcel / packages / core / core / src / EntryResolver.js View on Github external
async resolveEntry(entry: FilePath): Promise {
    if (isGlob(entry)) {
      let files = await glob(entry, this.fs, {
        absolute: true,
        onlyFiles: false,
      });
      let results = await Promise.all(files.map(f => this.resolveEntry(f)));
      return results.reduce(
        (p, res) => ({
          entries: p.entries.concat(res.entries),
          files: p.files.concat(res.files),
        }),
        {entries: [], files: []},
      );
    }

    let stat;
    try {
      stat = await this.fs.stat(entry);
github parcel-bundler / parcel / packages / transformers / stylus / src / StylusTransformer.js View on Github external
visitImport(imported) {
      let importedPath = imported.path.first.string;

      if (!deps.has(importedPath)) {
        if (isGlob(importedPath)) {
          deps.set(
            importedPath,
            glob(
              path.resolve(path.dirname(filepath), importedPath),
              parcelOptions.inputFS,
              {
                onlyFiles: true,
              },
            ).then(entries =>
              Promise.all(
                entries.map(entry =>
                  resolve(
                    filepath,
                    './' + path.relative(path.dirname(filepath), entry),
                  ),
                ),
              ),
            ),
          );