Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (fs.existsSync(_cookies.path)) {
_cookies.load();
request.get('https://plug.dj/_/users/me', {
headers: {
'User-Agent': 'plugAPI_' + PlugAPIInfo.version,
Cookie: _cookies.toString()
}
}, function(err, res) {
if (res.statusCode === 200) {
loggedIn = true;
}
loggingIn = false;
});
// Wait until the session is set
while (loggingIn) {
deasync.sleep(100);
}
}
if (!loggedIn) {
loggingIn = true;
request.get('https://plug.dj/', {
headers: {
'User-Agent': 'plugAPI_' + PlugAPIInfo.version,
Cookie: _cookies.toString()
}
}, function(err, res, body) {
var csrfToken;
_cookies.fromHeaders(res.headers);
csrfToken = body.split('_csrf')[1].split('"')[1];
step.stats = module._getStats(methodName);
} else {
step.stats = {};
}
if (err) {
step.failure = errorHelper.getFailureFromError(err);
// let the module decide whether a screenshot should be taken on error or not
if (typeof module._takeScreenshot === 'function') {
try {
step.screenshot = module._takeScreenshot(methodName);
}
catch (e) {
// If we are here, we were unable to get a screenshot
// Try to wait for a moment (in Perfecto Cloud, the screenshot might not be immidiately available)
deasync.sleep(1000);
try {
step.screenshot = module._takeScreenshot(methodName);
}
catch (e) {
// FIXME: indicate to user that an attempt to take a screenshot has failed
}
}
}
}
return step;
}
var lineColumn = getLineAndColumnFromStacktrace(err, scriptPath);
if (lineColumn) {
err.line = lineColumn.line;
err.column = lineColumn.column;
}
}
step.failure._line = err.line;
// let the module decide whether a screenshot should be taken on error or not
if (typeof module._takeScreenshot === 'function') {
try {
step.screenshot = module._takeScreenshot(methodName);
}
catch (e) {
// If we are here, we were unable to get a screenshot
// Try to wait for a moment (in Perfecto Cloud, the screenshot might not be immidiately available)
deasync.sleep(1000);
try {
step.screenshot = module._takeScreenshot(methodName);
}
catch (e) {
// FIXME: indicate to user that an attempt to take a screenshot has failed
}
}
}
}
rs.steps.push(step);
}
TestFS.prototype.statSync = function (filePath) {
var self = this;
var sync = true;
var data = null;
var syncErr = null;
self.stat(filePath, function(err, stat) {
data = stat;
syncErr = err;
sync = false;
});
while(sync) {require('deasync').sleep(100);}
if (syncErr) {
throw syncErr;
}
return data;
};
change(target) {
const filename = _getFilename(target);
deasync.sleep(10);
fs.writeFileSync(filename, 'new-value');
},
fileInfo(target) {
}
}
}
var done = false;
newImage.writeImage(newFilename, function(err) {
if(err) throw err;
console.log('wrote merged image');
done = true;
});
while(!done) {
deasync.sleep(1);
}
return newImage;
}
function getLatest(packageName) {
var sync = true;
var data = null;
npm.load({ parseable: true }, function (er, npm) {
if (er) {
sync = false;
return cb(er);
}
npm.commands.show([packageName, "version"], true, (version,x) => {
data = x;
sync = false;
});
})
while(sync) {require('deasync').sleep(100);}
return Object.keys(data)[0];
}
function readImageSync(fileLocation) {
var toReturn = null;
PNGImage.readImage(fileLocation, function (err, image) {
if (err) throw err;
toReturn = image;
});
while(toReturn == null) {
deasync.sleep(1);
}
return toReturn;
}
);
let sync = true;
let data = null;
compiler.outputFileSystem = fs;
compiler.run(err => {
if (err) {
throw err;
}
const fileContent = fs.readFileSync(bundlePath).toString('ascii');
data = requireFromString(fileContent);
sync = false;
});
while (sync) {
deasync.sleep(100);
}
return data;
};
setBasePort() {
this.getBasePort().then(basePort => {
this.basePort = basePort;
});
while (!this.basePort) sleep(100);
return true;
}