How to use fs-promise - 10 common examples

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 feramhq / typokit / index.js View on Github external
function getTypoMapsPromise () {
  return fsp
    .readdir(typoMapsPath)
    .then(fileNames => fileNames
      .filter(name => /\.yaml$/.test(name))
      .map(name => path.join(typoMapsPath, name))
    )
    .then(filePaths => Promise.all(
      filePaths.map(filePath => fsp.readFile(filePath))
    ))
    .then(fileContents => fileContents.map(yaml.safeLoad))
}
github ramoona / banks-db / lint.js View on Github external
jsonfile.readFile(path.join(__dirname, 'schema.json')).then((schema) => {
  fs.readdir(path.join(__dirname, 'banks')).then(files => lint(files, schema)).catch((err) => {
    logError(err);
    process.exit(1);
  });
}).catch(logError);
github heineiuo / seashell / src / cli.js View on Github external
function createService(program, callback){
  console.log('Creating auth file...')
  var service = {}
  var targetPath = program.targetPath || process.cwd()
  service.appId = uuid.v4()
  service.appName = program.appName || 'unnamed'
  service.appSecret = createSecret()

  var data = JSON.stringify(service, null, 2)

  fs.writeFile(targetPath+'/'+service.appId+'.json', data, 'UTF-8', function (err) {
    if (err) console.error(err)
    console.log('Create auth file in path '+targetPath)
  })

}
github heineiuo / seashell / packages / seashell-cli / cli.js View on Github external
function createService(program, callback){
  console.log('Creating auth file...')
  var service = {}
  var targetPath = program.targetPath || process.cwd()
  service.appId = uuid.v4()
  service.appName = program.appName || 'unnamed'
  service.appSecret = createSecret()

  var data = JSON.stringify(service, null, 2)

  fs.writeFile(targetPath+'/'+service.appId+'.json', data, 'UTF-8', function (err) {
    if (err) console.error(err)
    console.log('Create auth file in path '+targetPath)
  })

}
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);
    });
  });
};

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