How to use the recursive-readdir function in recursive-readdir

To help you get started, we’ve selected a few recursive-readdir 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 dsheiko / puppetry / src / component / AppLayout / TestReport / ReportBody.jsx View on Github external
async getAssetMap( dir ) {
    try {
      const dirPath = join( this.props.projectDirectory, dir ),
            files = await recursive( dirPath );

      return files.reduce( ( carry, filepath ) => {
        const filename = basename( filepath ),
              [ id ] = filename.split( "." ),
              newFilepath = ( dir === DIR_REPORTS ) ? filepath : `${ filepath }?${ Date.now() }`;
        carry[ id ] = result( carry, id, []);
        carry[ id ].push( newFilepath );
        return carry;
      }, {});
    } catch ( e ) {
      // e.g. nothing found
      return {};
    }
  }
github sorrycc / roadhog / src / buildDll.js View on Github external
return new Promise((resolve) => {
    // Clear babel cache directory
    rimraf.sync(paths.appBabelCache);

    // First, read the current file sizes in build directory.
    // This lets us display how much they changed later.
    recursive(appBuild, (err, fileNames) => {
      const previousSizeMap = (fileNames || [])
        .filter(fileName => /\.(js|css)$/.test(fileName))
        .reduce((memo, fileName) => {
          const contents = fs.readFileSync(fileName);
          const key = removeFileNameHash(fileName);
          memo[key] = gzipSize(contents);
          return memo;
        }, {});

      // Remove all content but keep the directory so that
      // if you're in it, you don't end up in Trash
      fs.emptyDirSync(appBuild);

      // Start the webpack build
      realBuild(previousSizeMap, resolve, argv);
    });
github ififfy / flipflip / src / renderer / components / player / SourceScraper.tsx View on Github external
return new CancelablePromise((resolve) => {
    recursiveReaddir(url, blacklist, (err: any, rawFiles: Array) => {
      if (err) {
        console.warn(err);
        resolve(null);
      } else {
        // If this is a local source (not a cacheDir call)
        if (helpers.next == null) {
          helpers.count = filterPathsToJustPlayable(IF.any, rawFiles, true).length;
        }
        resolve({
          data: filterPathsToJustPlayable(filter, rawFiles, true).map((p) => fileURL(p)).sort((a, b) => {
            let aFile: any = getFileName(a, false);
            if (parseInt(aFile)) {
              aFile = parseInt(aFile);
            }
            let bFile: any = getFileName(b, false);
            if (parseInt(aFile)) {
github google / clasp / src / files.ts View on Github external
export async function getProjectFiles(rootDir: string = path.join('.', '/'), callback: FilesCallback) {
  const { filePushOrder } = await getProjectSettings();

  // Load tsconfig
  const userConf = getTranspileOptions();

  // Read all filenames as a flattened tree
  // Note: filePaths contain relative paths such as "test/bar.ts", "../../src/foo.js"
  recursive(rootDir, async (err, filePaths) => {
    if (err) return callback(err, null, null);

    // Filter files that aren't allowed.
    const ignorePatterns = await DOTFILE.IGNORE();

    // Replace OS specific path separator to common '/' char for console output
    filePaths = filePaths.map((name) => name.replace(/\\/g, '/'));
    filePaths.sort(); // Sort files alphanumerically

    // dispatch with patterns from .claspignore
    const filesToPush: string[] = [];
    const filesToIgnore: string[] = [];
    filePaths.forEach(file => {
      if (multimatch(path.relative(rootDir, file), ignorePatterns, { dot: true }).length === 0) {
        filesToPush.push(file);
      } else {
github teambit / envs / packages / ts-compiler / src / compile.ts View on Github external
export async function collectDistFiles(context: CompilationContext): Promise {
  const capsuleDir = context.directory;
  const compDistRoot = path.resolve(capsuleDir, FIXED_OUT_DIR);
  const files = await readdir(compDistRoot);
  const readFiles = await Promise.all(
    files.map(file => {
      return fs.readFile(file);
    })
  );
  return files.map((file, index) => {
    const relativePath = path.relative(path.join(capsuleDir, FIXED_OUT_DIR), file);
    const pathToFile = path.join(compDistRoot, relativePath);
    let test = false;
    // Only check js files not d.ts or .map files
    if (getExt(relativePath) === 'js') {
      // Don't compare extension name, it will surly be different.
      // the source is ts / tsx and the dist is js.
      test = isTestFile(context.srcTestFiles, relativePath, false);
    }
    return new Vinyl({
github teppeis / duck / src / commands / buildJs.ts View on Github external
async function findEntryConfigs(entryConfigDir: string): Promise {
  const files = await recursive(entryConfigDir);
  return files.filter(file => /\.json$/.test(file));
}
github teambit / envs / packages / common / src / create-ts-compiler.ts View on Github external
async function collectNonDistFiles(context: CompilationContext, ignoreFunction: IgnoreFunction): Promise {
  const capsuleDir = context.directory
  const compDistRoot = path.resolve(capsuleDir, 'dist')
  const fileList = await readdir(capsuleDir, ['*.ts', '*.tsx', ignoreFunction])
  const readFiles = await Promise.all(
    fileList.map(file => {
      return fs.readFile(file)
    })
  )
  const list = fileList.map((file, index) => {
    const pathToFile = path.join(compDistRoot, file.split(capsuleDir)[1])

    return new Vinyl({
      path: pathToFile,
      contents: readFiles[index],
      base: compDistRoot,
    })
  })

  return list
github ipfs-shipyard / ipfs-desktop / src / webui / preload.js View on Github external
}, async (res) => {
        if (!res || res.length === 0) {
          return resolve()
        }

        const files = []

        const prefix = path.dirname(res[0])

        for (const path of await readdir(res[0])) {
          const size = (await fs.stat(path)).size
          files.push({
            path: path.substring(prefix.length, path.length),
            content: toPull.source(fs.createReadStream(path)),
            size: size
          })
        }

        resolve(files)
      })
    })
github Yoctol / bottender / packages / bottender / src / cli / providers / messenger / attachment.js View on Github external
)} is under heavy development. API may change between any versions.`
    );

    if (token) {
      accessToken = token;
    } else {
      const config = getConfig('bottender.config.js', 'messenger');

      invariant(config.accessToken, 'accessToken is not found in config file');

      accessToken = config.accessToken;
    }

    const client = MessengerClient.connect(accessToken);

    const files = await readdir('assets', ['.*']);

    invariant(files.length > 0, 'No files found in `assets` folder.');

    files.forEach(print);

    let confirm = true;
    if (!yes) {
      const promptResult = await inquirer.prompt([
        {
          type: 'confirm',
          message: force
            ? 'Are you sure you want to force upload all assets?'
            : 'Is it correct for uploading?',
          name: 'confirm',
        },
      ]);

recursive-readdir

Get an array of all files in a directory and subdirectories.

MIT
Latest version published 2 years ago

Package Health Score

74 / 100
Full package analysis