How to use the readdirAsync function from fs-extra

Find comprehensive JavaScript fs-extra.readdirAsync code examples handpicked from public code repositorys.

216
217
218
219
220
221
222
223
224
225
if (this.options['extend-drupal8']) {
  this.options.extend.unshift(path.resolve(__dirname, 'extend-drupal8'));
}
this.options.extend.forEach(directory => {
  prepTasks.push(
    fs.readdirAsync(directory).then(files => {
      files.forEach(fileName => {
        if (path.extname(fileName) === '.js') {
          let extendFunction = require(path.join(directory, fileName));
          // istanbul ignore else
fork icon293
star icon1
watch icon2

166
167
168
169
170
171
172
173
174
175
);

// Load Handlebars helpers.
this.config.helpers.forEach(directory => {
  initTasks.push(
    fs.readdirAsync(directory).then(helperFiles => {
      helperFiles.forEach(fileName => {
        if (path.extname(fileName) === '.js') {
          let helper = require(path.join(directory, fileName));
          // istanbul ignore else
fork icon293
star icon0
watch icon2

46
47
48
49
50
51
52
53
54
55
  console.info(colors.white('      ace.js'))
  let result = uglify.minify(items.join(';\n'), { output: { 'max_line_len': 1000000 } })
  return fs.writeFileAsync('./assets/js/ace/ace.js', result.code)
}),
// Modes
fs.readdirAsync('./node_modules/brace/mode').then(modeList => {
  return Promise.map(modeList, mdFile => {
    return fs.readFileAsync(path.join('./node_modules/brace/mode', mdFile), 'utf8').then(modeCode => {
      console.info(colors.white('      mode-' + mdFile))
      let result = uglify.minify(modeCode, { output: { 'max_line_len': 1000000 } })
fork icon0
star icon1
watch icon4

+ 3 other calls in file

143
144
145
146
147
148
149
150
151
152
async parseTestdata(dir, submitAnswer) {
  if (!await syzoj.utils.isDir(dir)) return null;

  try {
    // Get list of *files*
    let list = await (await fs.readdirAsync(dir)).filterAsync(async x => await syzoj.utils.isFile(path.join(dir, x)));

    let res = [];
    if (!list.includes('data.yml')) {
      res[0] = {};
fork icon0
star icon0
watch icon1

+ 21 other calls in file

function icon

fs-extra.readFileSync is the most popular function in fs-extra (9724 examples)