Beispiel #1
0
 return fs.readdirSync(packagesPath).reduce((acc, d) => {
   const fullpath = path.resolve(packagesPath, d);
   if (fs.statSync(fullpath).isDirectory()) {
     try {
       fs.statSync(path.resolve(fullpath, `package.json`));
       acc.push(fullpath);
     }
     catch (err) {
       if (err.code === `ENOENT`) {
         return acc.concat(findPackages(fullpath));
       }
       throw err;
     }
   }
   return acc;
 }, []);
Beispiel #2
0
function findPkgPath(pkgPath) {
  if (pkgPath.endsWith(`package.json`)) {
    return pkgPath;
  }

  try {
    const filePath = `${pkgPath}.json`;
    fs.statSync(filePath);
    return filePath;
  }
  catch (err) {
    const dirPath = path.resolve(pkgPath, `package.json`);
    fs.statSync(dirPath);
    return dirPath;
  }
}
Beispiel #3
0
    this.files.forEach((file) => {
      if (fs.statSync(file.src[0]).isDirectory()) {
        return;
      }

      const instrumented = instrumenter.instrumentSync(grunt.file.read(file.src[0]), file.src[0]);
      grunt.file.write(file.dest, instrumented);
    });
Beispiel #4
0
  function getResolveLoader() {
    const root = [path.resolve(directory, `node_modules`)]

    const userLoaderDirectoryPath = path.resolve(directory, `loaders`)

    try {
      if (fs.statSync(userLoaderDirectoryPath).isDirectory()) {
        root.push(userLoaderDirectoryPath)
      }
    } catch (err) {
      debug(`Error resolving user loaders directory`, err)
    }

    return {
      modules: [...root, path.join(__dirname, `../loaders`), `node_modules`],
    }
  }
Beispiel #5
0
  function getResolveLoader() {
    const root = [path.resolve(directory, `node_modules`)]

    const userLoaderDirectoryPath = path.resolve(directory, `loaders`)

    try {
      if (fs.statSync(userLoaderDirectoryPath).isDirectory()) {
        root.push(userLoaderDirectoryPath)
      }
    } catch (err) {
      debug(`Error resolving user loaders directory`, err)
    }

    return {
      modules: [...root, path.join(__dirname, `../loaders`), `node_modules`],
      // Bare loaders should always be loaded via the user dependencies (loaders
      // configured via third-party like gatsby use require.resolve)
      plugins: [PnpWebpackPlugin.moduleLoader(`${directory}/`)],
    }
  }
Beispiel #6
0
const findEntryPoints = _.curry((pkg, pkgPath) => {
  try {
    let paths = [];

    if (pkg.main) {
      paths.push(path.resolve(path.dirname(pkgPath), pkg.main));
    }

    if (paths.length === 0) {
      try {
        const p = path.resolve(path.dirname(pkgPath), `index.js`);
        fs.statSync(p);
      }
      catch (err) {
        if (err.code !== `ENOENT`) {
          throw err;
        }
      }
    }

    if (pkg.bin) {
      paths = paths.concat(_.values(pkg.bin));
    }

    if (pkg.browser) {
      paths = paths.concat(_.values(pkg.browser).filter((p) => p && !p.startsWith(`@`)));
    }

    return paths;
  }
  catch (err) {
    if (err.code === `EISDIR`) {
      return findEntryPoints(pkg, path.join(pkgPath, `package.json`));
    }

    throw err;
  }
});
t.notThrows(() => fs.statSync(downloadFilePath));
 return fs.readdirSync(srcpath).filter((file) => fs.statSync(path.join(srcpath, file)).isDirectory());