How to use the graceful-fs.readFileSync 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 robtweed / ewd.js / lib / masterProcess / httpServer.js View on Github external
var ok = ewd.customWebServerRequestHandler(requestObj, response);
          if (ok) return;
        }
        */

        fileRequestHandler(httpParams);
      });
    };

    // WebServer definition - https or http

    if (ewd.https.enabled) {
      var https = require("https");
      var options = {
        key: fs.readFileSync(ewd.https.keyPath),
        cert: fs.readFileSync(ewd.https.certificatePath),
        // turn off SSL 3.0 to protect against POODLE vulnerability
        secureProtocol: 'SSLv23_method',
        secureOptions: constants.SSL_OP_NO_SSLv3,
      };
      if (ewd.traceLevel >= 1) console.log("HTTPS is enabled; listening on port " + ewd.httpPort);
      webServer = https.createServer(options, webserverCallback);
      // Start HTTP listening service for GT.M/Cache to use for WebSockets events
    }
    else {
      if (ewd.traceLevel >= 1) console.log("HTTP is enabled; listening on port " + ewd.httpPort);
      var http = require("http");
      webServer = http.createServer(webserverCallback);
    }
    webServer.on('error', function(e) {
        console.log('**** Error reported by web server: ' + e.code + ': ' + e.message + ' *****');
        if (e.code === 'EADDRINUSE' || e.code === 'EACCES') {
github hoodiehq-archive / hoodie-cli / lib / cli / help.js View on Github external
// help file directory
  var basepath = path.join(__dirname, '..', '..', 'doc', 'cli');
  var filepath;
  var data;

  // filename format: command.command.txt
  filepath = argv._.slice(0);
  filepath.push('txt');
  filepath = filepath.join('.');

  // full path
  filepath = path.join(basepath, filepath);

  // get help info and replace $0 with process name
  data = fs.readFileSync(filepath, 'utf8');
  data = data.trim().replace(/\$0/g, argv.$0);

  console.log('\n' + data + '\n');

  callback(null);
};
github NuSkooler / enigma-bbs / core / servers / content / web.js View on Github external
createServer(cb) {
        if(this.enableHttp) {
            this.httpServer = http.createServer( (req, resp) => this.routeRequest(req, resp) );
        }

        const config = Config();
        if(this.enableHttps) {
            const options = {
                cert    : fs.readFileSync(config.contentServers.web.https.certPem),
                key     : fs.readFileSync(config.contentServers.web.https.keyPem),
            };

            //  additional options
            Object.assign(options, config.contentServers.web.https.options || {} );

            this.httpsServer = https.createServer(options, (req, resp) => this.routeRequest(req, resp) );
        }

        return cb(null);
    }
github assemble / assemble / test / dest.js View on Github external
var onEnd = function(){
      buffered.length.should.equal(1);
      buffered[0].should.equal(expectedFile);
      buffered[0].cwd.should.equal(expectedCwd, 'cwd should have changed');
      buffered[0].base.should.equal(expectedBase, 'base should have changed');
      buffered[0].path.should.equal(expectedPath, 'path should have changed');
      fs.existsSync(expectedPath).should.equal(true);
      bufEqual(fs.readFileSync(expectedPath), expectedContents).should.equal(true);
      realMode(fs.lstatSync(expectedPath).mode).should.equal(expectedMode);
      done();
    };
github ocelotds / ocelot / ocelot-dashboard / gulpfile.js View on Github external
gulp.task("init", function () {
		if (fs.existsSync(".bowerrc")) {
			var bowerrc = JSON.parse(fs.readFileSync(".bowerrc", "utf-8"));
			if (bowerrc.directory) {
				vendorsFolder = bowerrc.directory;
			}
		}
		gconfig.dist = util.env.dist || gconfig.dist;
		gconfig.rootApp = util.env.rootapp || gconfig.rootApp;

		gconfig.jsName = util.env.jsname || gconfig.jsName;
		gconfig.cssName = util.env.cssname || gconfig.cssName;
		gconfig.bowerJs = util.env.bowerjs || gconfig.bowerJs;
		console.log(" - target directory:", gconfig.dist);
		console.log(" - vendors libs directory:", vendorsFolder);
		console.log(" - vendors result js file:", gconfig.bowerJs);
		console.log(" - application source directory:", gconfig.rootApp);
		console.log(" - application main js file:", gconfig.jsName);
		console.log(" - application main css file:", gconfig.cssName);
github Financial-Times / polyfill-service / tasks / node / buildsources.js View on Github external
.then(data => {
				this.config = JSON.parse(data);
				this.config.detectSource = '';
				this.config.baseDir = this.path.relative;

				if ('licence' in this.config) {
					throw `Incorrect spelling of license property in ${this.name}`;
				}

				this.config.hasTests = fs.existsSync(path.join(this.path.absolute, 'tests.js'));
				this.config.isTestable = !('test' in this.config && 'ci' in this.config.test && this.config.test.ci === false);
				this.config.isPublic = this.name.indexOf('_') !== 0;

				if (fs.existsSync(this.detectPath)) {
					this.config.detectSource = fs.readFileSync(this.detectPath, 'utf8').replace(/\s*$/, '') || '';
					validateSource(`if (${this.config.detectSource}) true;`, `${this.name} feature detect from ${this.detectPath}`);
				}
			});
	}
github EveryBit-com / everybit.js / client-angular / node_modules / bower / node_modules / bower-config / lib / util / rc.js View on Github external
function json(file) {
    var content;

    try {
        content = fs.readFileSync(file).toString();
    } catch (err) {
        return null;
    }

    return parse(content, file);
}
github hongmaoxiao / now / node_modules / load-json-file / index.js View on Github external
module.exports.sync = function (fp) {
	return parse(fs.readFileSync(fp, 'utf8'), fp);
};
github Financial-Times / polyfill-service / service / routes / docs.js View on Github external
['header', 'footer', 'nav'].forEach(partialName => {
	Handlebars.registerPartial(partialName, Handlebars.compile(
		fs.readFileSync(path.join(__dirname, '/../../docs/'+partialName+'.html'), {encoding: 'UTF-8'})
	));
});
github ionic-team / stencil / src / sys / node_next / node-sys.ts View on Github external
readFileSync(p) {
      try {
        return fs.readFileSync(p, 'utf8');
      } catch (e) {}
      return undefined;
    },
    realpath(p) {