Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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') {
// 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);
};
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);
}
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();
};
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);
.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}`);
}
});
}
function json(file) {
var content;
try {
content = fs.readFileSync(file).toString();
} catch (err) {
return null;
}
return parse(content, file);
}
module.exports.sync = function (fp) {
return parse(fs.readFileSync(fp, 'utf8'), fp);
};
['header', 'footer', 'nav'].forEach(partialName => {
Handlebars.registerPartial(partialName, Handlebars.compile(
fs.readFileSync(path.join(__dirname, '/../../docs/'+partialName+'.html'), {encoding: 'UTF-8'})
));
});
readFileSync(p) {
try {
return fs.readFileSync(p, 'utf8');
} catch (e) {}
return undefined;
},
realpath(p) {