Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const jobArgs = {
captureProcessorType: this._captureProcessorType,
browserSession: browserSession.serialize(),
page: _.omit(page, 'coverage'),
execOpts: {
refImg: {path: browserConfig.getScreenshotPath(state.suite, state.name), size: null},
pixelRatio: page.pixelRatio,
antialiasingTolerance: browserConfig.antialiasingTolerance,
tolerance,
compareOpts: browserConfig.compareOpts
},
temp: temp.serialize()
};
return Promise.fromCallback((cb) => this._workers(jobArgs, cb))
.catch(err => Promise.reject(errorUtils.fromPlainObject(err)))
.then(result => _.extend(result, {coverage, tolerance}));
}
};
openSite (event, site) {
event.preventDefault()
Promise.fromCallback(cb => this.adapter.openSite(site, cb))
.catch(err => {
console.error(err)
})
},
saveDebugData () {
mounted () {
this.clipboard = this.$electron.remote.clipboard
this.adapter = this.$electron.remote.require('./main').homeAdapter
Promise.all([
Promise.fromCallback(cb => this.adapter.getPortsAllocation(cb)),
Promise.fromCallback(cb => this.adapter.getIp(cb)),
Promise.fromCallback(cb => this.adapter.getModulesDisplayNames(cb))
])
.then(([portsAllocation, ip, dispalyNames]) => {
this.modules = Object.entries(portsAllocation)
.map(([module, port]) => ({
name: dispalyNames[module],
site: `http://${ip}:${port}/`
}))
})
.catch(err => {
console.error(err)
})
}
}
async _loadJobs() {
const ignorePaths = [(file, stats) => {
return !(new RegExp(/.*job.js/g).test(file)) && !stats.isDirectory();
}];
return Promise
.fromCallback(cb => recursive(path.join(__dirname, './../jobs'), ignorePaths, cb))
.map(require)
.map(Job => this._startJob(Job));
}
const importFile: Importer = async (fileToImport, options) => {
const {
ids = [uniqueId('imported_image_')],
workspaceId,
} = options;
const [imageId] = ids;
const actions: GenericAction[] = [
loadImageStarted({ imageId, workspaceId }),
];
const dataURL = await readFileAsDataURL(fileToImport);
const img = new Image();
img.src = dataURL;
const { height, width } = await bluebird.fromCallback(cb => {
img.onload = () => cb(null, img);
img.onerror = ({ error }) => cb(error, null);
});
actions.push(loadImageSucceeded({
id: imageId,
name: fileToImport.name,
data: dataURL,
height,
width,
}));
actions.push(setActiveImageId({ imageId, workspaceId }));
return actions;
};
destroy() {
return P.fromCallback(cb => this.client.close(cb));
}
if (options.tsconfig) {
b.plugin(tsify, { project: options.tsconfig });
}
b.exclude('aws-sdk');
let srcPaths = [], paths = [];
b.pipeline.get('deps').push(through.obj((row, enc, next) => {
let p = path.relative('', row.file || row.id);
srcPaths.push(p);
saveTranslatedOutput(p, stageDir, row.source)
.then(n => { paths.push(n); next(); });
}));
return bluebird.fromCallback(cb => b.bundle(cb))
.then(() => getPackageFiles(srcPaths))
.then(pkgPaths => paths.concat(pkgPaths).sort());
}
exports.collectDependencies = collectDependencies;
return tslib_1.__awaiter(this, void 0, void 0, function* () {
let data = _.extend({}, req.params, req.query, req.body);
let options = {
abortEarly: false,
allowUnknown: true,
stripUnknown: true
};
try {
let params = yield Q.fromCallback((callback) => joi.validate(data, route.validations, options, callback));
let output = {};
if (route.convertToCamelCase !== false) {
for (let key in params) {
output[util_1.Util.convertSnakeCaseToCamelCase(key)] = params[key];
}
}
else {
output = params;
}
req.model = output;
next();
}
catch (e) {
res.status(400).jsonp({
status: 400,
statusText: "Bad Request",
].map( ([from, to]) => {
return Promise.fromCallback( callback => {
fs.rename(from, to, callback)
}).catch( err => {
if (err.code !== 'ENOENT') {
throw err;
}
})
})).then( () => {
if (!this.options.disableAutoCommit) {
const group = this.session.dataStore.getGroupById(key);
const dm = this.session.dataStore.getDMById(key);
if (channel) {
this.storeChannels.set(key, R.assoc('_is_channel', true, channel.toJSON()));
} else if (group) {
this.storeChannels.set(key, R.assoc('_is_group', true, group.toJSON()));
} else if (dm) {
this.storeChannels.set(key, R.assoc('_is_dm', true, dm.toJSON()));
}
if (this.storeChannels.get(key)) {
return Promise.resolve(this.storeChannels.get(key));
}
const pchannel = Promise.fromCallback((done) =>
this.sessionWeb.channels.info(key, done))
.catch((error) => error === 'channel_not_found' ? null : { error });
const pgroup = Promise.fromCallback((done) =>
this.sessionWeb.groups.info(key, done))
.catch((error) => error === 'channel_not_found' ? null : { error });
return Promise.join(pchannel, pgroup, (chan, grp) => {
if (!chan.error) {
return R.assoc('_is_channel', true, chan.channel);
} else if (!grp.error) {
return R.assoc('_is_group', true, grp.group);
} else if (!chan.error && !grp.error) {
return {
_is_dm: true,
id: key,