How to use recursive-readdir - 10 common examples

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 vutran / os-fonts / __tests__ / index.js View on Github external
it('should get all network fonts', async () => {
            // set up mock data
            recursive.__setFiles(['foo.ttf', 'bar.ttf', 'baz.ttf', 'qux.ttf']);
            const fonts = await m.getAll('network');
            expect(fonts.length).toBe(4);
        });
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 toshi1127 / css-optimization / cli / src / bin / cli.ts View on Github external
async function main(pg) {
  debug(pg);
  const { parallel, path: caseDir, ...options } = prepare(pg);

  if (cluster.isMaster) {
    const files = ((await readdir(
      path.resolve(process.cwd(), caseDir)
    )) as string[])
      .sort()
      .filter(f => {
        return f.endsWith("yaml") || f.endsWith("yml");
      });
    if (!parallel) {
      // single thread
      for (const f of files) {
        await pprun({ file: f, options });
      }
      return;
    }
    // multi thread
    const pNum = Math.max(numCPUs, parallel);
    for (let i = 0; i < pNum; i++) {
github vutran / os-fonts / __tests__ / index.js View on Github external
it('should return nothing for readdir errors', async () => {
            recursive.__setReturnError(true);
            const fonts = await m.getAll('network');
            expect(fonts.length).toBe(0);
        });
    });
github Yoctol / bottender / packages / bottender / src / cli / providers / messenger / __tests__ / uploadAttachment.spec.js View on Github external
beforeEach(() => {
    _client = {
      getPageInfo: jest.fn(),
      uploadAttachment: jest.fn(),
    };
    MessengerClient.connect = jest.fn(() => _client);
    getConfig.mockReturnValue(MOCK_FILE_WITH_PLATFORM.messenger);
    readdir.mockResolvedValue([
      {
        name: 'The X-Files',
      },
    ]);
    inquirer.prompt = jest.fn();
    inquirer.prompt.mockResolvedValue({
      confirm: true,
    });
    process.exit = jest.fn();
  });
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));
}

recursive-readdir

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

MIT
Latest version published 1 year ago

Package Health Score

71 / 100
Full package analysis