How to use the @now/build-utils.glob function in @now/build-utils

To help you get started, we’ve selected a few @now/build-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 juicyfx / now-builders / src / php-bridge / index.js View on Github external
return [];
  }

  if (configuration.getVersion(config) === '7.4') {
    console.log('🐘 Skip Composer (calling PHP 7.4 is not supported at this moment)');
    return [];
  }

  console.log('🐘 Installing Composer deps.');

  // Install composer dependencies
  await runComposerInstall({ workPath, config });

  console.log('🐘 Installing Composer deps OK.');

  return await glob('vendor/**', workPath);
}
github zeit / now / packages / now-python / src / index.ts View on Github external
const tempDir = await getWriteableDirectory();
    await installRequirement({
      dependency: 'pipfile-requirements',
      workPath: tempDir,
      meta,
      args: ['--no-warn-script-location'],
    });

    // Python needs to know where to look up all the packages we just installed.
    // We tell it to use the same location as used with `--target`
    process.env.PYTHONPATH = tempDir;
    const convertCmd = join(tempDir, 'bin', 'pipfile2req');
    await pipenvConvert(convertCmd, pipfileLockDir);
  }

  fsFiles = await glob('**', workPath);
  const requirementsTxt = join(entryDirectory, 'requirements.txt');

  if (fsFiles[requirementsTxt]) {
    debug('Found local "requirements.txt"');
    const requirementsTxtPath = fsFiles[requirementsTxt].fsPath;
    await installRequirementsFile({
      filePath: requirementsTxtPath,
      workPath,
      meta,
    });
  } else if (fsFiles['requirements.txt']) {
    debug('Found global "requirements.txt"');
    const requirementsTxtPath = fsFiles['requirements.txt'].fsPath;
    await installRequirementsFile({
      filePath: requirementsTxtPath,
      workPath,
github zeit / now / packages / now-static-build / src / index.ts View on Github external
export async function prepareCache({
  entrypoint,
  workPath,
  config,
}: PrepareCacheOptions): Promise {
  // default cache paths
  const defaultCacheFiles = await glob('node_modules/**', workPath);

  // framework specific cache paths
  let frameworkCacheFiles: { [path: string]: FileFsRef } | null = null;

  const pkg = getPkg(entrypoint, workPath);
  if (pkg) {
    const framework = getFramework(config, pkg);

    if (framework && framework.cachePattern) {
      frameworkCacheFiles = await glob(framework.cachePattern, workPath);
    }
  }

  return { ...defaultCacheFiles, ...frameworkCacheFiles };
}
github zeit / now / packages / now-next / src / index.ts View on Github external
const pkg = await readPackageJson(entryPath);
  const nextVersion = getNextVersion(pkg);
  if (!nextVersion) throw new Error('Could not parse Next.js version');
  const isLegacy = isLegacyNext(nextVersion);

  if (isLegacy) {
    // skip caching legacy mode (swapping deps between all and production can get bug-prone)
    return {};
  }

  debug('Producing cache file manifest...');
  const cacheEntrypoint = path.relative(workPath, entryPath);
  const cache = {
    ...(await glob(path.join(cacheEntrypoint, 'node_modules/**'), workPath)),
    ...(await glob(path.join(cacheEntrypoint, '.next/cache/**'), workPath)),
  };
  debug('Cache file manifest produced');
  return cache;
};
github zeit / now / packages / now-node / src / index.ts View on Github external
const inputFiles = new Set([entrypointPath]);

  const sourceCache = new Map();
  const fsCache = new Map();
  const tsCompiled = new Set();

  let shouldAddSourcemapSupport = false;

  if (config.includeFiles) {
    const includeFiles =
      typeof config.includeFiles === 'string'
        ? [config.includeFiles]
        : config.includeFiles;

    for (const pattern of includeFiles) {
      const files = await glob(pattern, workPath);
      await Promise.all(
        Object.keys(files).map(async file => {
          const entry: FileFsRef = files[file];
          fsCache.set(file, entry);
          const stream = entry.toStream();
          const { data } = await FileBlob.fromStream({ stream });
          if (file.endsWith('.ts') || file.endsWith('.tsx')) {
            sourceCache.set(
              file,
              compileTypeScript(resolve(workPath, file), data.toString())
            );
          } else {
            sourceCache.set(file, data);
          }
          inputFiles.add(resolve(workPath, file));
        })
github zeit / now / packages / now-static-build / src / index.ts View on Github external
) {
          distPath = publicPath;
        }
      }

      validateDistDir(distPath, meta.isDev, config);

      if (framework) {
        const frameworkRoutes = await getFrameworkRoutes(
          framework,
          outputDirPrefix
        );
        routes.push(...frameworkRoutes);
      }

      output = await glob('**', distPath, mountpoint);
    }

    const watch = [path.join(mountpoint.replace(/^\.\/?/, ''), '**/*')];
    return { routes, watch, output, distPath };
  }

  if (!config.zeroConfig && entrypoint.endsWith('.sh')) {
    debug(`Running build script "${entrypoint}"`);
    const nodeVersion = await getNodeVersion(entrypointDir, undefined, config);
    const spawnOpts = getSpawnOptions(meta, nodeVersion);
    await runShellScript(path.join(workPath, entrypoint), [], spawnOpts);
    validateDistDir(distPath, meta.isDev, config);

    const output = await glob('**', distPath, mountpoint);

    return {