Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function readAndUnlinkP(p) {
return new Promise((resolve, reject) => {
readFileP(p)
.then((img) => {
unlinkP(p)
.then(() => resolve(img))
.catch(reject);
})
.catch(reject);
});
}
if (process.platform === 'darwin') {
screenshot.darwinSnapshot = function darwinSnapshot(options = {}) {
return new Promise((resolve, reject) => {
const displayId = options.screen || 0;
if (!Number.isInteger(displayId) || displayId < 0) {
reject(new Error(`Invalid choice of displayId: ${displayId}`));
} else {
const format = options.format || 'jpg';
let filename;
let suffix;
if (options.filename) {
const ix = options.filename.lastIndexOf('.');
suffix = ix >= 0 ? options.filename.slice(ix) : `.${format}`;
filename = '"' + options.filename.replace(/"/g, '\\"') + '"' // eslint-disable-line
} else {
suffix = `.${format}`;
}
const snapshotFunc = () => {
switch (process.platform) {
case 'darwin':
return screenshot.darwinSnapshot;
case 'win32':
case 'windows':
return screenshot.windowsSnapshot;
default:
return screenshot;
}
};
const images = yield eff.all(