How to use the readFileAsync function from fs-extra

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

182
183
184
185
186
187
188
189
190
191
  );
});

return Promise.all(initTasks).then(() => {
  // Compile the Handlebars template.
  return fs.readFileAsync(path.resolve(this.config.builder, 'index.html'), 'utf8').then(content => {
    this.template = this.Handlebars.compile(content);
    return Promise.resolve();
  });
});
fork icon293
star icon0
watch icon2

+ 3 other calls in file

4
5
6
7
8
9
10
11
12
13
var logger = require('AppFramework').logger;
var Installer = function () {
};
Installer.prototype.Install = function (installDir) {
  logger.info('Installing...');
  return fs.readFileAsync(path.resolve(installDir, './manifest.json')).then(JSON.parse).then(function (manifest) {
    return Promise.map(manifest.preinstall, function (script) {
      // Run pre-install scripts
      logger.info('Executing pre-install script: ' + script.name);
      return ExecuteScript(installDir, script);
fork icon94
star icon63
watch icon33

+ 3 other calls in file

72
73
74
75
76
77
78
79
80
81
  return 0
}

var getPackage = main.getPackage = function (packagePath) {
  packagePath = (packagePath) ? packagePath : './package.json'
  return fs.readFileAsync(packagePath, 'utf8')
  .then(JSON.parse)
  .then(function (pkg) {
    pkg.path = packagePath
    return pkg
fork icon5
star icon45
watch icon5

160
161
162
163
164
165
166
167
168
    return fs.readFileAsync(filepath, 'utf-8');
  }
});

return Promise.all([
    fs.readFileAsync(manifestXml, 'utf-8')
  ].concat(readPluginXMLFiles))
  .then(function (results) {
    var xml = results.shift();
fork icon22
star icon14
watch icon49

+ 7 other calls in file

35
36
37
38
39
40
41
42
43
44
console.info(colors.white('  └── ') + colors.green('Copy + Minify ACE modes to assets...'))
return fs.ensureDirAsync('./assets/js/ace').then(() => {
  return Promise.join(
    // Core
    Promise.all([
      fs.readFileAsync('./node_modules/brace/index.js', 'utf8'),
      fs.readFileAsync('./node_modules/brace/ext/modelist.js', 'utf8'),
      fs.readFileAsync('./node_modules/brace/theme/dawn.js', 'utf8'),
      fs.readFileAsync('./node_modules/brace/theme/tomorrow_night.js', 'utf8'),
      fs.readFileAsync('./node_modules/brace/mode/markdown.js', 'utf8')
fork icon0
star icon1
watch icon4

+ 11 other calls in file

48
49
50
51
52
53
54
55
56
57
if (!this._cache[profile]) {
    this._cache[profile] = {};
}
promises.push(fs.statAsync(localFile).then((stat) => {
    if (!stat.isDirectory()) {
        return fs.readFileAsync(localFile, {encoding: 'utf-8'}).then((data) => {
            this._cache[profile][name] = data;
        })
    }
}));
fork icon0
star icon1
watch icon1

186
187
188
189
190
191
192
193
194
195
    return 0;
  });

  res.spj = list.some(s => s.startsWith('spj_'));
} else {
  let config = require('js-yaml').load((await fs.readFileAsync(dir + '/data.yml')));

  let input = config.inputFile, output = config.outputFile, answer = config.userOutput;

  res = config.subtasks.map(st => ({
fork icon0
star icon0
watch icon1

+ 21 other calls in file

132
133
134
135
136
137
138
139
140
141
142
143
}


function addToIml(file) {
  var str = `<orderEntry type="library" name="shang-auto-generate" level="project" />`;


  return fs.readFileAsync(file.path)
    .then(function (buffer) {
      var data = buffer.toString();
      data = data.replace(str, '');
      data = data.replace('</component>', `  ${str}\n  </component>`);
fork icon0
star icon0
watch icon0

+ 27 other calls in file

152
153
154
155
156
157
158
159
160
161

let buildTasks = [];

// Compile the Handlebars template.
buildTasks.push(
  fs.readFileAsync(path.resolve(this.options.builder, 'index.html'), 'utf8').then(content => {
    this.template = this.Handlebars.compile(content);
    return Promise.resolve();
  })
);
fork icon0
star icon0
watch icon2

+ 3 other calls in file

83
84
85
86
87
88
89
90
91
92
function readLocaleFile(file) {
  return fs.readFileAsync(file, { encoding: 'utf8' });
}

function readTypeScriptLocaleFile(file) {
  return fs.readFileAsync(file, { encoding: 'utf8' }).catch(err => {

    // Ignore the error if it indicates that the file doesn't exist
    // (it just means that the compiled translation file is being generated
    // for the first time on this machine)
fork icon0
star icon0
watch icon4

+ 5 other calls in file

function icon

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