示例#1
0
async function findNativeModules() {
  const nodeModules = path.join(__dirname, '..', 'node_modules');
  const files = await fs.walk(nodeModules);

  const modules = {};
  for (const { path: filepath, stats } of files) {
    if (!stats.isFile()) {
      continue;
    }

    // Native modules have `binding.gyp` at the top level.
    if (path.basename(filepath) === 'binding.gyp') {
      const modulePath = path.dirname(filepath);

      // Check it is at the top level.
      if (path.basename(path.dirname(modulePath)) !== 'node_modules') {
        continue;
      }

      try {
        const moduleManifest = await fs.readJson(path.join(modulePath, 'package.json'));
        modules[path.relative(nodeModules, modulePath)] = moduleManifest.version;
      } catch (e) {
        // Ignore bad modules
      }
    }
  }

  return modules;
}
示例#2
0
文件: render.js 项目: ukatama/nekodoc
 (dirname) => walk(dirname)
     .then((entries) => entries
         .map((entry) => ({
             path: relative(dirname, entry.path)
                 .split(sep)
                 .join('/'),
         }))
         .filter(({path}) => Boolean(path))
     );
示例#3
0
export async function babelBuild(source) {
  const paths = await fs.walk(source);

  // Find all the directories, and make sure they all exist in the build path.
  const dirs = paths.filter(p => p.stats.isDirectory());
  await Promise.all(dirs.map(p => fs.ensureDir(getBuildPath(p.path))));

  // Build all the files.
  const files = paths.filter(p => p.stats.isFile());
  await Promise.all(files.map(p => babelFile(p.path, p.stats)));
}
示例#4
0
async function babelBuild() {
  const source = path.resolve(path.join(__dirname, '..', 'app'));

  const paths = await fs.walk(source);

  // Find all the directories and sort by depth.
  const dirs = paths.filter(p => p.stats.isDirectory())
                  .sort((a, b) => a.length - b.length);

  // Make sure they all exist in the target directory.
  await Promise.all(dirs.map(p => fs.ensureDir(getTargetPath(p.path))));

  // Build all the files
  const files = paths.filter(p => p.stats.isFile());
  await Promise.all(files.map(p => buildFile(p.path, p.stats)));
}