How to use the fs.exists function in fs

To help you get started, we’ve selected a few 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 busterc / dotenv-assert / index.js View on Github external
'or empty arguments to dotenv-assert. Please see the official README.md for details.';
      throw new OptionsError(errorMessage);
    }

    assertFilePath = options.filePath || assertFilePath;

    if (typeof callback !== 'function') {
      errorMessage = '    The callback is not a function';
      throw new CallbackError(errorMessage);
    }
  }

  if (assertFilePath.indexOf('/') > -1) {

    // look for explicit file location
    fs.exists(assertFilePath, function(exists) {
      if (!exists) {
        errorMessage = assertFilePath + ' does not exist.';
        throw new FileNotFoundError(errorMessage);
      }

      settings = getSettingsFromFile({
        'assertFilePath': assertFilePath
      });
      assertSettings(settings);

      callback();
    });
  } else {

    // find the file in $CWD or the nearest parent directory
    findParentDir(CURRENT_WORKING_DIRECTORY, assertFilePath, function(error, directory) {
github arangodb / arangodb / tests / js / client / permissions / filesystem.js View on Github external
function tryExistsForbidden(fn) {
    try {
      let rc = fs.exists(fn);
      fail();
    }
    catch (err) {
      assertEqual(arangodb.ERROR_FORBIDDEN, err.errorNum, 'stat-access to ' + fn + ' wasn\'t forbidden');
    }
    try {
      let rc = fs.mtime(fn);
      fail();
    }
    catch (err) {
      assertEqual(arangodb.ERROR_FORBIDDEN, err.errorNum, 'stat-access to ' + fn + ' wasn\'t forbidden');
    }
  }
  function tryExistsAllowed(fn, exists) {
github zeit / pkg / test / test-50-fs-runtime-layer / test-x3-index.js View on Github external
fs.exists(firstLowerCase(path.join(__dirname, theRequireContentA)), function (e85, v85) {
fs.exists(firstLowerCase(__dirname + path.sep + theRequireContentB), function (e86, v86) {
fs.exists(firstLowerCase(__dirname + '/' + theRequireContentB), function (e87, v87) {
fs.exists(firstUpperCase(path.join(__dirname, theRequireContentA)), function (e88, v88) {
fs.exists(firstUpperCase(__dirname + path.sep + theRequireContentB), function (e89, v89) {
fs.exists(firstUpperCase(__dirname + '/' + theRequireContentB), function (e90, v90) {
//

fs.exists(path.join(__dirname, theRequireContentA + '-no-such'), function (e91, v91) {
fs.exists(__dirname + path.sep + theRequireContentB + '-no-such', function (e92, v92) {
fs.exists(__dirname + '/' + theRequireContentB + '-no-such', function (e93, v93) {
fs.exists(firstLowerCase(path.join(__dirname, theRequireContentA + '-no-such')), function (e94, v94) {
fs.exists(firstLowerCase(__dirname + path.sep + theRequireContentB + '-no-such'), function (e95, v95) {
fs.exists(firstLowerCase(__dirname + '/' + theRequireContentB + '-no-such'), function (e96, v96) {
fs.exists(firstUpperCase(path.join(__dirname, theRequireContentA + '-no-such')), function (e97, v97) {
fs.exists(firstUpperCase(__dirname + path.sep + theRequireContentB + '-no-such'), function (e98, v98) {
fs.exists(firstUpperCase(__dirname + '/' + theRequireContentB + '-no-such'), function (e99, v99) {
//
github r3b / speedreport / core / speedreport.js View on Github external
/*if(!phantom.args[1]){
        fileid = phantom.args[0].replace('http://','').replace('https://','').replace(/\//g,'');
        fileid = fileid.split('?')[0];
        myjson = 'speedreports/' + fileid + '.js';
        myfile = 'speedreports/' + fileid + '.' + extension;
    }else{
        fileid = phantom.args[1];
        myjson = 'speedreports/' + fileid + '.js';
        myfile = 'speedreports/' + fileid + '.' + extension;
    }*/

    if(myfile!==null){
        try {
            data = "var reportdata = " + data + ";";
            if(fs.exists(myfile)){
                fs.remove(myfile);
            }
            if(!fs.exists('templates/speedreport.html')){
                console.error("Unable to find template: %s", 'templates/speedreport.html');
                phantom.exit();
            }else{
                html = fs.read('templates/speedreport.html');
            }
            html=html.replace('{{REPORT_DATA_URI}}', fileid + '.js');
            if(phantom.args[1]){
                html=html.replace('{{url}}', phantom.args[1]);
            }else{
                html=html.replace('{{url}}', phantom.args[0]);
            }

            f = fs.open(myfile, "w");
github Scriptol / Advanced-Explorer / aexplorer.js View on Github external
function loadBrowser(filename)
{
	var param="http://localhost:1032/" + filename;
	var browserName = explorer.config.browser;
    var browser = explorer.config[browserName];
    if(browserName=='')
    {
      browser = explorer.config.chrome;
      browserName='Chrome';
    }
    
    console.log('Loading browser: '+ browser);

	fs.exists(browser, function(result) {
		if(!result) { console.log("File not found " + browser); return 0; }
		var command = browser +  " " + param;
		console.log("Running " + command);
		runner.exec(command, function(err, stdout, stderr) { 
        console.log("Terminated. "+ stderr); 
    });
	});

}
github G33kLabs / Node.VaSH / libs / server / express.vash.site.js View on Github external
register: function(callback) {
			    		fs.exists(widgetFilename, function(exists) {
			    			if ( exists ) {
			    				tools.log('Register widget :: '+'widget.'+data+'.js') ;
			    				self.get('assets').js.push(widgetFilename.split(root_path)[1]) ;
			    				widget = new (require(widgetFilename).widget)(_.extend({}, self.attributes, {templates: self.templates}, widget)) ;
			    			}
			    			callback(null, widget) ;
			    		}); 	    				
	    			},
	    			template: function(callback) {
github hijiangtao / UrbanFACET / conf / entropy.js View on Github external
function generateGridsJson(locs, obj) {
    fs.exists('myjsonfile.json', function(exists) {
        if (exists) {
            console.log("yes file exists");
        } else {
            console.log("file not exists");

            var json = JSON.stringify(obj);
            fs.writeFile('myjsonfile.json', json);
        }
    });
}
github biggora / caminte-generator / bin / caminte.js View on Github external
function existsFile(path, fn) {
    fs.exists(path, function (exists) {
        fn(exists);
    });
}
github kartotherian / kartotherian / packages / tilerator / lib / storage.js View on Github external
fs.existsAsync = BBPromise.promisify(function (path, callback) {
    fs.exists(path, function (exists) {
        callback(null, exists);
    });
});
github coq-community / vscoq / server / src / util / nodejs-async.ts View on Github external
return new Promise((resolve,reject) => {
      nfs.exists(path, (ex) => resolve(ex));
    });
  }

fs

This package name is not currently in use, but was formerly occupied by another package. To avoid malicious use, npm is hanging on to the package name, but loosely, and we'll probably give it to you if you want it.

ISC
Latest version published 8 years ago

Package Health Score

67 / 100
Full package analysis