How to use the fs-extra.readdir function in fs-extra

To help you get started, we’ve selected a few fs-extra 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 namics / frontend-defaults / cli / __tests__ / shared.tsx View on Github external
const tmpPath = path.join(tmpPathRoot, tmpPathName);
	options.cwd = tmpPath;
	if (options.force === undefined) {
		options.force = true;
	}

	jest.setTimeout(10000);
	await deleteDir(tmpPath);
	try {
		await fs.mkdir(tmpPathRoot);
	} catch (err) {}
	await fs.mkdir(tmpPath);

	await api(options);

	const files = (await fs.readdir(tmpPath))
		.filter((dirName: string) => !fs.statSync(path.join(tmpPath, dirName)).isDirectory())
		.filter(removeIgnoredFiles)
		.sort();

	let i = 0;
	for (i = 0; i < files.length; i += 1) {
		const fileData = await fs.readFile(path.join(tmpPath, files[i]), 'utf8');
		const tree = renderer.create().toJSON();
		expect(tree).toMatchSnapshot();
	}

	// normalize pathes to look the same on windows, linux and mac
	// expect.addSnapshotSerializer({
	// 	test: (val) => typeof val === 'string',
	// 	print(val) {
	// 		return `${val.replace(/\\/g, '/')}`;
github stream-labs / streamlabs-obs / test / selective-recording.ts View on Github external
// Check that source is set to record only
  t.true(await client.isExisting('.sl-vue-tree-sidebar .source-selector-action.icon-studio'));

  // Start recording
  await client.click('.record-button');
  await sleep(2000);

  // Ensure recording indicator is active
  t.true(await client.isExisting('.record-button.active'));

  // Stop recording
  await client.click('.record-button');
  await client.waitForVisible('.record-button:not(.active)', 60000);

  // Check that file exists
  const files = await readdir(tmpDir);
  t.is(files.length, 1);
});
github mayeaux / nodetube / lib / livestreaming / postNewRecordings.js View on Github external
async function main(){

  const folderToScan = './recordings';

  fs.readdir(folderToScan, (err, files) => {

    // console.log(files);

    if(!files){
      console.log('no files in directory')
      return
    }

    files.forEach(async (file) => {

      // console.log(file);

      const split = file.split('&');

      const username = split[0];
      const filename = split[1];
github MMF-FE / wepy-template / template / tools / tpl / generate.js View on Github external
function writeFiles (type, distPath, data) {
    let tplPath = path.join(__dirname, type)

    fs.readdir(tplPath, 'utf8', (err, files) => {
        if (err) {
            console.log(colors.red(err))
            return false
        }

        files.forEach((filename) => {
            let content = compile(path.join(tplPath, filename), data)
            let distFileName = data.name + '.' + filename.split('.')[1]

            let filePath = path.join(distPath, distFileName)

            console.log(colors.green('write file: '))
            console.log(colors.underline(filePath))
            fs.writeFileSync(filePath, content, 'utf8')
        })
github repetere / periodicjs / lib / init / folderStructure.js View on Github external
.then(() => { //check to make sure there arent two config files (both a json and a js file, if there are both, use the json file)
            return fs.readdir(path.join(this.config.app_root, 'content/config'));
          })
          .then(configFiles => {
github kyma-project / website / tools / content-loader / src / documentation / copy.js View on Github external
async getFilesPaths(path) {
    const type = await fs.stat(path);
    if (type.isFile()) return path;

    const paths = await fs.readdir(path);

    const filesPromises = paths.map(
      async p => await this.getFilesPaths(`${path}/${p}`),
    );

    const files = await Promise.all(filesPromises);
    const flattenFiles = files.reduce(
      (arr, x) => (Array.isArray(x) ? [...arr, ...x] : [...arr, x]),
      [],
    );

    return flattenFiles;
  }
github dadi / cdn / dadi / lib / models / workspace.js View on Github external
return queue.then(() => {
      return fs.readdir(directoryPath).then(items => {
        directories.push({
          items,
          type
        })
      })
    })
  }, Promise.resolve())
github adaptlearning / adapt_authoring / plugins / output / adapt / importsourcecheck.js View on Github external
async.each(plugindata.pluginTypes, function iterator(pluginType, doneMapIterator) {
          var srcDir = path.join(COURSE_ROOT_FOLDER, Constants.Folders.Source, pluginType.folder);

          if (!fs.existsSync(srcDir)) {
            logger.log('info', 'No plugins found.');
            return doneMapIterator();
          }
          fs.readdir(srcDir, function (err, files) {
            if (err) {
              return doneMapIterator(err);
            }
            files.map(function (file) {
              return path.join(srcDir, file);
            }).filter(function (file) {
              return fs.statSync(file).isDirectory();
            }).forEach(function (file) {
              var data = _.extend(_.clone(pluginType), { location: file });
              plugindata.pluginIncludes.push(data);
            });
            doneMapIterator();
          });
        }, function(err) {
          if(err) {
github repetere / periodicjs / lib / extension / setup.js View on Github external
return new Promise((resolve, reject) => {
    try {
      const standardModelsDir = (container.name) ?
        (container.type === 'local') ?
        `${this.config.app_root}/content/container/${container.name}/config/databases/standard/models` :
        `${this.config.app_root}/node_modules/${container.name}/config/databases/standard/models` :
        `${this.config.app_root}/node_modules/${extension.name}/config/databases/standard/models`;
      const modelFilesMap = getModelFilesMap.bind(standardModelsDir);
      fs.readdir(standardModelsDir)
        .then(modelFiles => {
          const modelFilesFullPath = modelFiles.map(file => getModelFilesMap(standardModelsDir, file));
          this.resources.standard_models.push(...modelFilesFullPath);
          resolve(true);
        }).catch(e => {
          resolve('does not have standard models');
        });
    } catch (e) {
      reject(e);
    }
  });
}