How to use the fs-extra2.readJsonSync function in fs-extra2

To help you get started, we’ve selected a few fs-extra2 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 avwo / whistle / lib / plugins / get-plugins-sync.js View on Github external
Object.keys(plugins).forEach(function(name) {
    var simpleName = name.split('.', 2)[1];
    if (protocols.contains(simpleName)) {
      return;
    }
    var dir = plugins[name];
    var isSys = dir.isSys;
    dir = dir.root;
    try {
      var pkgPath = path.join(dir, 'package.json');
      var pkg = fse.readJsonSync(pkgPath);
      if (pkg && pkg.version) {
        var stats = fs.statSync(pkgPath);
        var conf = pkg.whistleConfig || '';
        var hintList = util.getHintList(conf);
        var plugin = {
          isSys: isSys,
          moduleName: pkg.name,
          networkMenus: util.getPluginMenu(conf.networkMenus || conf.networkMenu, simpleName),
          rulesMenus: util.getPluginMenu(conf.rulesMenus || conf.rulesMenu, simpleName),
          valuesMenus: util.getPluginMenu(conf.valuesMenus || conf.valuesMenu, simpleName),
          pluginHomepage: pluginUtil.getPluginHomepage(pkg, simpleName),
          priority: parseInt(conf.priority, 10) || parseInt(pkg.pluginPriority, 10) || 0,
          rulesUrl: util.getCgiUrl(conf.rulesUrl),
          valuesUrl: util.getCgiUrl(conf.valuesUrl),
          hintUrl: hintList ? undefined : util.getCgiUrl(conf.hintUrl),
          hideShortProtocol: !!conf.hideShortProtocol,
github avwo / whistle / bin / util.js View on Github external
function readConfig(storage) {
  var dataDir = getDataDir();
  var configFile = path.join(dataDir, encodeURIComponent('#' + (storage ? storage + '#' : '')));
  if (!fs.existsSync(configFile)) {
    return;
  }
  try {
    return fse.readJsonSync(configFile);
  } catch(e) {}
}

fs-extra2

fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as mkdir -p, cp -r, and rm -rf.

MIT
Latest version published 7 months ago

Package Health Score

64 / 100
Full package analysis