How to use glob-promise - 10 common examples

To help you get started, we’ve selected a few glob-promise 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 chrisathook / display-standard-previewer / gulp / test-definitions.js View on Github external
it('no SVG IDs should be duplicates must be GLOBAL UNIQUE ', function () {
    let files = glob.sync(src);
    files.forEach(function (file) {
      
      // inventory of all styles in each file
      let inventory = {};
      inventory.file = file;
      let content = fs.readFileSync(file, 'utf8');
      let matches = [];
      try {
        
        matches = content.match(/id\=\"(.*?)\"/g);
      } catch (err) {
      }
      let trimmed = [];
      matches.forEach(function (match) {
        trimmed.push(match.replace('.', '').replace('{', ''))
      });
github expo / expo / tools / expotools / src / versioning / android / index.ts View on Github external
async function cleanUpAsync(version: string) {
  const abiVersion = version.replace(/\./g, '_');
  const abiName = `abi${abiVersion}`;

  const versionedAbiSrcPath = path.join(
    versionedExpoviewAbiPath(abiName),
    'src/main/java',
    abiName
  );

  let filesToDelete: string[] = [];

  // delete PrintDocumentAdapter*Callback.java
  // their package is `android.print` and therefore they are not changed by the versioning script
  // so we will have duplicate classes
  const printCallbackFiles = await glob(path.join(
    versionedAbiSrcPath,
    'expo/modules/print/*Callback.java'
  ));
  for (const file of printCallbackFiles) {
    const contents = await fs.readFile(file, 'utf8');
    if (!contents.includes(`package ${abiName}`)) {
      filesToDelete.push(file);
    } else {
      console.log(`Skipping deleting ${file} because it appears to have been versioned`);
    }
  }

  // delete versioned loader providers since we don't need them
  filesToDelete.push(path.join(versionedAbiSrcPath, 'expo/loaders'));

  console.log('Deleting the following files and directories:');
github edsilv / biiif / Utils.ts View on Github external
public static async getThumbnail(json: any, directory: Directory, filePath?: string): Promise {
        let fp: string = filePath || directory.directoryPath;
        fp = Utils.normaliseFilePath(fp);

        const thumbnailPattern: string = fp + '/thumb.*';
        const thumbnails: string[] = await glob(thumbnailPattern);

        if (thumbnails.length) {
            // there's alrady a thumbnail in the directory, add it to the canvas
            console.log(chalk.green('found thumbnail for: ') + fp);
            let thumbnail: string = thumbnails[0];
            const thumbnailJson: any = Utils.cloneJson(thumbnailBoilerplate);
            thumbnailJson[0].id = Utils.mergePaths(directory.url, Utils.getVirtualFilePath(thumbnail, directory));
            json.thumbnail = thumbnailJson;
        } else if (directory.generateThumbs) {
            // there isn't a thumbnail in the directory, so we'll need to generate it.
            
            // if debugging: jimp item.getitem is not a function
            // generate thumbnail
            if (json.items && json.items.length && json.items[0].items) {
                // find an annotation with a painting motivation of type image.
                const items: any[] =  json.items[0].items;
github edsilv / biiif / Directory.ts View on Github external
public async read(): Promise {

        // canvases are directories starting with an underscore
        const canvasesPattern: string = this.directoryPath + '/_*';

        const canvases: string[] = await glob(canvasesPattern, {
            ignore: [
                '**/*.yml',
                '**/thumb.*'
            ]
        });

        // sort canvases 
        canvases.sort((a, b) => {
            return Utils.compare(a, b);
        });

        await Promise.all(canvases.map(async (canvas: string) => {
            console.log(chalk.green('creating canvas for: ') + canvas);
            this.items.push(new Canvas(canvas, this));
        }));
github epsagon / serverless-plugin-epsagon / src / index.js View on Github external
await Promise.all(this.funcs.map(async (func) => {
      const handler = _.isString(func.handler) ? func.handler.split('.') : [];
      const relativePath = handler.slice(0, -1).join('.');
      const matchingFiles = glob.sync(`${relativePath}.*`);
      if (
        matchingFiles.length > 0 &&
           (matchingFiles[0].endsWith('.ts') ||
            matchingFiles[0].endsWith('.tsx'))
      ) {
        // This is a good enough test for now. lets treat it as TS.
        func.language = 'tsnode'; // eslint-disable-line no-param-reassign
      }
    }));
  }
github expo / expo-cli / dev / xdl / src / detach / OldAndroidDetach.js View on Github external
path.join(androidProjectDirectory, 'app', 'src', 'main', 'java'),
    ANDROID_TEMPLATE_PKG,
    packageName
  );
  await renamePackageAsync(
    path.join(androidProjectDirectory, 'app', 'src', 'test', 'java'),
    ANDROID_TEMPLATE_PKG,
    packageName
  );
  await renamePackageAsync(
    path.join(androidProjectDirectory, 'app', 'src', 'androidTest', 'java'),
    ANDROID_TEMPLATE_PKG,
    packageName
  );

  let packageNameMatches = await glob(androidProjectDirectory + '/**/*.@(java|gradle|xml)');
  if (packageNameMatches) {
    let oldPkgRegex = new RegExp(`${ANDROID_TEMPLATE_PKG.replace(/\./g, '\\.')}`, 'g');
    for (let i = 0; i < packageNameMatches.length; i++) {
      await regexFileAsync(packageNameMatches[i], oldPkgRegex, packageName);
    }
  }

  // Fix app name
  logger.info('Naming Android project...');
  let appName = manifest.name;
  await regexFileAsync(
    path.resolve(androidProjectDirectory, 'app', 'src', 'main', 'res', 'values', 'strings.xml'),
    ANDROID_TEMPLATE_NAME,
    appName
  );
github expo / expo-cli / packages / xdl / src / detach / IosPodsTools.js View on Github external
async function _concatTemplateFilesInDirectoryAsync(directory, filterFn) {
  let templateFilenames = (await glob(path.join(directory, '*.rb'))).sort();
  let filteredTemplateFilenames = filterFn ? templateFilenames.filter(filterFn) : templateFilenames;
  let templateStrings = [];
  // perform this in series in order to get deterministic output
  for (let fileIdx = 0, nFiles = filteredTemplateFilenames.length; fileIdx < nFiles; fileIdx++) {
    const filename = filteredTemplateFilenames[fileIdx];
    let templateString = await fs.readFile(filename, 'utf8');
    if (templateString) {
      templateStrings.push(templateString);
    }
  }
  return templateStrings.join('\n');
}
github zeit / next.js / server / resolve.js View on Github external
// OSX: HFS+ stores filenames in NFD (decomposed normal form) Unicode format,
  // so we must ensure that the input path is in that format first.
  if (process.platform === 'darwin') fsPathNormalized = fsPathNormalized.normalize('NFD')

  // !! Windows: Curiously, the drive component mustn't be part of a glob,
  // !! otherwise glob.sync() will invariably match nothing.
  // !! Thus, we remove the drive component and instead pass it in as the 'cwd'
  // !! (working dir.) property below.
  var pathRoot = parse(fsPathNormalized).root
  var noDrivePath = fsPathNormalized.slice(Math.max(pathRoot.length - 1, 0))

  // Perform case-insensitive globbing (on Windows, relative to the drive /
  // network share) and return the 1st match, if any.
  // Fortunately, glob() with nocase case-corrects the input even if it is
  // a *literal* path.
  const result = await glob(noDrivePath, { nocase: true, cwd: pathRoot })
  return result[0]
}
github highlightjs / highlight.js / tools / build_browser.js View on Github external
function installDemoStyles() {
  log("Writing style files.");
  mkdir("demo/styles");

  glob.sync("*", {cwd: "./src/styles"}).forEach((file) => {
    if (file.endsWith(".css"))
      install_cleancss(`./src/styles/${file}`,`demo/styles/${file}`);
    else // images, backgrounds, etc
      install(`./src/styles/${file}`,`demo/styles/${file}`);
  })
}
github ProjectEvergreen / greenwood / test / cli.spec.js View on Github external
it('should output one JS bundle', async() => {
      expect(await glob.promise(path.join(CONTEXT.publicDir, './**/index.*.bundle.js'))).to.have.lengthOf(1);
    });

glob-promise

Promise version of glob

MIT
Latest version published 8 months ago

Package Health Score

73 / 100
Full package analysis