How to use the glob.promise function in glob

To help you get started, we’ve selected a few 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 eva-org / eva-core / app / base_plugin / FindApp / index.js View on Github external
if (isMac) {
      config.patterns = ['/Applications/**.app', `${os.homedir()}/Downloads/**.**`]
      config.command = 'open '
    } else if (isWindows) {
      config.patterns = ['C:/ProgramData/Microsoft/Windows/Start Menu/Programs/**.lnk']
      config.command = ''
    } else if (isLinux) {
      // TODO linux support. Pull request needed.
    } else {
      logger.error('Not support current system.')
    }
    saveConfig('findApp', config)
  }

  for (const pattern of config.patterns) {
    await glob.promise(pattern, (err, file) => {
      if (err) {
        logger.error(err)
        return
      }
      files = files.concat(file.toString().split(',').filter(() => true))
    })
  }

  //加载缓存
  const cacheFileExist = fs.existsSync(cachePath)
  files.forEach(file => {
    searchCache[file] = 0
  })
  if (cacheFileExist) {
    Object.assign(searchCache, JSON.parse(fs.readFileSync(cachePath).toString()))
  } else {
github biuuu / ShinyColors / script / deploy.js View on Github external
const start = async () => {
  await fse.emptyDir('./dist/data/')
  const hash = await md5Dir('./data/')
  console.log(hash)
  await fse.writeJSON('./dist/manifest.json', { 
    hash, version, moduleId, 
    cyweb_token, trans_api, language,
    date: getDate(8) 
  })
  console.log('story...')
  const files = await glob.promise('./data/story/**/*.csv')
  const prims = files.map(file => {
    return readCsv(file).then(list => {
      for (let i = list.length - 1; i >= 0; i--) {
        if (list[i].id === 'info') {
          if (list[i].name) {
            const name = list[i].name.trim()
            if (name) {
              return [name, file.replace(/^\./, '')]
            }
          }
        }
      }
    })
  })
  const result = await Promise.all(prims)
  const storyData = result.filter(item => {
github syntaxhighlighter / syntaxhighlighter / build / bundle.js View on Github external
function getAvailableBrushes(rootPath) {
  const glob = require('glob');

  return glob.promise(`${rootPath}/repos/brush-*`)
    .then(brushes => brushes.map(path => path.match(/brush-(.*)$/)[1]));
}
github syntaxhighlighter / syntaxhighlighter / build / bundle.js View on Github external
function getAvailableBrushes(rootPath) {
  const glob = require('glob');

  return glob.promise(`${rootPath}/repos/brush-*`)
    .then(brushes => brushes.map(path => path.match(/brush-(.*)$/)[1]));
}
github expo / xdl / src / Simulator.js View on Github external
async function isExponentAppInstalledOnCurrentBootedSimulatorAsync() {
  let device = await bootedSimulatorDeviceAsync();
  if (!device) {
    return false;
  }
  let simDir = await dirForSimulatorDevice(device.udid);
  let matches = await glob.promise('./data/Containers/Data/Application/*/Library/Caches/Snapshots/host.exp.Exponent', {cwd: simDir});
  return (matches.length > 0);
}