Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'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) {
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) {
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) {
//
/*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");
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);
});
});
}
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) {
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);
}
});
}
function existsFile(path, fn) {
fs.exists(path, function (exists) {
fn(exists);
});
}
fs.existsAsync = BBPromise.promisify(function (path, callback) {
fs.exists(path, function (exists) {
callback(null, exists);
});
});
return new Promise((resolve,reject) => {
nfs.exists(path, (ex) => resolve(ex));
});
}