How to use the fs-promise.readFile function in fs-promise

To help you get started, we’ve selected a few fs-promise 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 twosigma / git-meta / node / lib / util / git_util.js View on Github external
exports.editMessage = co.wrap(function *(repo, initialContents) {
    const messagePath = path.join(repo.path(), "COMMIT_EDITMSG");
    yield fs.writeFile(messagePath, initialContents);
    const editorCommand = yield exports.getEditorCommand(repo);

    // TODO: if we ever need this to work on Windows, we'll need to do
    // something else.  The `ChildProcess.exec` method doesn't provide for a
    // way to auto-redirect stdio or I'd use it.

    yield ChildProcess.spawn("/bin/sh",
                             ["-c", `${editorCommand} '${messagePath}'`], {
        stdio: "inherit",
    });
    return yield fs.readFile(messagePath, "utf8");
});
github twosigma / git-meta / node / lib / util / git_util.js View on Github external
exports.editMessage = co.wrap(function *(repo, initialContents) {
    const messagePath = path.join(repo.path(), "COMMIT_EDITMSG");
    yield fs.writeFile(messagePath, initialContents);
    const editorCommand = yield exports.getEditorCommand(repo);

    // TODO: if we ever need this to work on Windows, we'll need to do
    // something else.  The `ChildProcess.exec` method doesn't provide for a
    // way to auto-redirect stdio or I'd use it.

    yield ChildProcess.spawn("/bin/sh",
                             ["-c", `${editorCommand} '${messagePath}'`], {
        stdio: "inherit",
    });
    return yield fs.readFile(messagePath, "utf8");
});
github base16-builder / base16-builder / util / schemesPreviewGenerator.js View on Github external
return Promise.all(promises).then(function(yamlSchemes) {
      yamlSchemes = yamlSchemes.map(yamlScheme => yaml.load(yamlScheme));
      return fs
        .readFile(path.join(__dirname, './schemesPreview.ejs'), 'utf-8')
        .then(function(templ) {
          const preview = ejs.render(templ, {
            schemes: yamlSchemes
          });
          return fs.writeFile(path.join(__dirname, '../dist/index.html'), preview);
        });
    });
  })
github kossnocorp / chirrapp / scripts / buildHTML.js View on Github external
function readManifest() {
  return fsp
    .readFile(path.resolve(rootPath, 'dist/app/webpack-assets.json'))
    .then(content => JSON.parse(content))
}
github kossnocorp / chirrapp / scripts / buildHTML.js View on Github external
function buildTemplate() {
  return fsp
    .readFile(path.join(rootPath, 'index.ejs'))
    .then(templateContent => ejs.compile(templateContent.toString()))
}
github elrumordelaluz / svgson / bin / svgson.js View on Github external
return new Promise((resolve, reject) => {
    return fs.readFile(file, 'utf-8').then(data => {
      svgson(data, applyExtras(fileName), resolve);
    });
  });
};
github elrumordelaluz / svgson / bin / svgson.js View on Github external
return new Promise((resolve,reject) => {
    return fs.readFile(filePath, 'utf8').then(data => {
      process.stdout.cursorTo(0);
      process.stdout.clearLine();
      process.stdout.write(file);
      svgson(data, applyExtras(fileName), resolve);
    });
  });
};
github twosigma / git-meta / node / lib / util / sequencer_state_util.js View on Github external
exports.readFile = co.wrap(function *(gitDir, name) {
    assert.isString(gitDir);
    assert.isString(name);
    const filePath = path.join(gitDir, SEQUENCER_DIR, name);
    try {
        return yield fs.readFile(filePath, "utf8");
    }
    catch (e) {
        return null;
    }
});
github compactd / compactd / main.js View on Github external
async function checkFile() {
  const file = path.join(config.get('dataDirectory'), 'testfile');
  const key = shortid.generate();
  await fs.writeFile(file, `testfile.${key}`);
  const res = await fs.readFile(file, 'utf8');
  await fs.unlink(file);
  const stillExists = await fs.exists(file);

  if (res === `testfile.${key}` && !stillExists) {
    return;
  }
  throw new Error('Unknown reason');
}

fs-promise

[DEPRECATED] Use mz or fs-extra^3.0 with Promise Support

MIT
Latest version published 7 years ago

Package Health Score

50 / 100
Full package analysis