How to use the graceful-fs.existsSync function in graceful-fs

To help you get started, we’ve selected a few graceful-fs 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 jspm / jspm-cli / lib / config / global-config.js View on Github external
function GlobalConfigFile(homePath) {
  this.globalConfigFile = homePath + path.sep + '.jspm' + path.sep + 'config';
  this.config = null;
  // global config - automatically created and loaded on startup
  this.registries = [];

  // old windows HOME migration
  // can deprecate with jspm 0.15.3
  if (process.env.USERPROFILE && HOME !== process.env.USERPROFILE && !fs.existsSync(path.join(HOME, '.jspm')) && fs.existsSync(path.join(process.env.USERPROFILE, '.jspm'))) {
    var OLD_HOME = process.env.USERPROFILE;
    var from = path.join(OLD_HOME, '.jspm');
    var to = path.join(HOME, '.jspm');
    ui.log('info', 'Migrating global jspm folder from `' + from + '` to `' + to + '`...');
    try {
      ui.log('info', 'Copying configuration...');
      var oldConfig = fs.readFileSync(path.resolve(from, 'config'));
      mkdirp.sync(to);
      fs.writeFileSync(path.resolve(to, 'config'), oldConfig);
      ui.log('ok', 'Migration successful. Note that linked packages will need to be relinked.');
    }
    catch (e) {
      ui.log('err', 'Error migrating to new jspm folder\n' + (e && e.stack || e));
    }
  }
github shama / navelgazer / lib / navelgazer.js View on Github external
var platform = module.exports = function(file, cb, done) {
  // Ignore non-existent files
  if (!fs.existsSync(file)) return;

  // Mark every folder
  file = markDir(file);

  // Helper for when to use statpoll
  function useStatPoll() {
    return statpoll(file, function(event) {
      var filepath = file;
      cb(null, event, filepath);
    });
  }

  // By default try using native OS watchers
  if (platform.mode === 'auto' || platform.mode === 'watch') {
    // Delay adding files to watch
    // Fixes the duplicate handle race condition when renaming files
github krakenjs / makara / test / resolver.js View on Github external
it('should resolve a nested file', function () {
            var file,
                fileName = 'inc/partial';
            res = resolver.create(config);
            file = res.resolve(fileName);
            assert(file.file, 'A known file was not found');
            assert(fs.existsSync(file.file), 'The resolved file does not exist on disk.');
            assert(file.name === fileName, 'Inconsistent file name');
            assert(path.resolve(file.root) === path.resolve(config.root), 'Root path doesn\'t match.');
        });
github hw2-archive / upt / test / core / resolveCache.js View on Github external
Q.all([store(), store2()]).then(function (dirs) {
                var dir = dirs[0];
                expect(dir).to.equal(path.join(cacheDir, md5('foo'), 'foo%2Fbar'));
                expect(fs.existsSync(dir)).to.be(true);
                expect(fs.existsSync(path.join(dir, 'baz'))).to.be(true);
                expect(fs.existsSync(tempPackage)).to.be(false);
                expect(fs.existsSync(tempPackage2)).to.be(false);

                next();
            }).done();
        });
github MrLuit / EtherScamDB / generate.js View on Github external
layout = layout.replace(/{{ scam.history }}/ig, history);
        layout = layout.replace(/{{ scam.actions }}/ig, actions);
        layout = layout.replace(/{{ scam.name }}/ig, scams[key]['name']);
        if (!fs.existsSync("./_site/scam/" + scams[key]['id'] + "/")) {
            fs.mkdirSync("./_site/scam/" + scams[key]['id'] + "/");
        }
        if (minify) {
            layout = htmlmin(layout);
        }
        fs.writeFile("./_site/scam/" + scams[key]['id'] + "/index.html", layout, function(err) {
            if (err) {
                return console.log(err);
            }
        });
    }
    if (!fs.existsSync("./_site/address/")) {
        fs.mkdirSync("./_site/address/");
    }
    Object.keys(addresses).forEach(function(key) {
        var layout = template.replace("{{ content }}", layout_addresses);
        var related = "";
        for (var i = 0, len = addresses[key].length; i < len; i++) {
            related += "<div class="item"><a href="/scam/&quot; + addresses[key][i] + &quot;">" + data.find(o =&gt; o['id'] === addresses[key][i])['name'] + "</a></div>";
        }
        if (related) {
            related = '<div class="ui bulleted list">' + related + '</div>';
        } else {
            related = "None";
        }
        layout = layout.replace(/{{ address.address }}/ig, key);
        layout = layout.replace(/{{ address.scams }}/ig, related);
        if (!fs.existsSync("./_site/address/" + key + "/")) {
github gameclosure / devkit / src / AddonManager.js View on Github external
this.clone = function (cb) {
			//check if the registry exists
			if (!fs.existsSync(REGISTRY_PATH)) {
				//create the directory structure and clone it
				wrench.mkdirSyncRecursive(REGISTRY_PATH);

				logger.log("Cloning from", REGISTRY_URL, "please wait (this may take a minute...)");
				this._client('clone', REGISTRY_URL, ".", cb);
			} else {
				cb();
			}
		}
github hexojs / hexo-fs / lib / fs.js View on Github external
function mkdirsSync(path) {
  if (!path) throw new TypeError('path is required!');

  const parent = dirname(path);
  const exist = fs.existsSync(parent);

  if (!exist) mkdirsSync(parent);
  fs.mkdirSync(path);
}
github gameclosure / devkit / src / PackageManager.js View on Github external
function listFilesSync (base, exts) {
	var ret = new EventEmitter();
	var files = []
	if (fs.existsSync(base)) {
		findit.sync(base, function (file, stat) {
			if (stat.isFile() && (exts || []).indexOf(path.extname(file).substr(1)) >= 0) {
				files.push({name: path.basename(file, path.extname(file)), path: file, stat: stat});
			}
		});
	}
	return files;
};
github gyselroth / balloon-client-desktop / app / lib / instance.js View on Github external
return new Promise(function(resolve, reject) {
      if(fs.existsSync(archiveDir) === false) return createDataDir(clientConfig, instanceName);

      var balloonDir = clientConfig.get('balloonDir');
      fs.rename(archiveDir, balloonDir, (err) => {
        if(err) return reject(err);

        logger.info('successfully extracted archived data dir', {
          category: 'instance',
          archive: balloonDir
        });
        resolve();
      });
    });
  }
github gyselroth / balloon-client-desktop / tasks / build_app.js View on Github external
gulp.task('build', function () {
    var envName = utils.getEnvName();
    var srcPath = path.join(__dirname, '../config/', `env_${envName}.json`);
    var destPath = path.join(__dirname, '../resources/', 'env.json');

    if(fs.existsSync(srcPath)) {
      if(fs.existsSync(destPath)) {
        fs.truncateSync(destPath, 0);
      }

      fs.createReadStream(srcPath).pipe(fs.createWriteStream(destPath));
    } else if(envName !== 'production') {
      fs.writeFile(destPath, '{"name": "'+envName+'"}', function(err) {
        if(err) {
          throw err;
        }
      });
    }
});