Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function resizeExpectedImage (cb) {
tmp.tmpName({postfix: '.png'}, function (err, filepath) {
// If there was an error, callback
if (err) {
return cb(err);
}
// If there was no expected image, create a transparent image to compare against
expectedTmpPath = filepath;
if (expectedSize.doesNotExist) {
gm(maxWidth, maxHeight, 'transparent').write(expectedTmpPath, cb);
// Otherwise, resize the image
} else {
transparentExtent(gm(expectedPath), {
width: maxWidth,
height: maxHeight
}).write(expectedTmpPath, cb);
}
function resizeActualImage (cb) {
// Get a temporary filepath
tmp.tmpName({postfix: '.png'}, function (err, filepath) {
// If there was an error, callback
if (err) {
return cb(err);
}
// Otherwise, resize the image
actualTmpPath = filepath;
transparentExtent(gm(actualPath), {
width: maxWidth,
height: maxHeight
}).write(actualTmpPath, cb);
});
},
function resizeExpectedImage (cb) {
return new Promise((resolve, reject) => {
tmp.tmpName(options, (err, name) => {
if (err)
reject(err);
else
resolve(name);
});
});
}
function (next) {
tmp.tmpName({ template: template }, next);
},
function (temp, next) {
function grepAsync(regex, text, callback){
var tmp = require('tmp');
tmp.tmpName(function _tempNameGenerated(err, path) {
if (err) throw err;
fs.writeFileSync(path, text);
var result = sh.grep(regex, path);
callback(result);
});
}
return new Promise((resolve, reject) => {
const tmp = require("tmp");
tmp.tmpName(options, function(err: any, path: string) {
if (err) {
reject(err);
} else {
resolve(path);
}
});
});
}
}
completedInvoked = true;
try {
if (err) {
reject(err);
}
else {
resolve(result);
}
}
finally {
tryUnlinkTempFile(tempFile, opts);
}
};
try {
TMP.tmpName(toTmpSimpleOptions(opts), (err, path) => {
if (err) {
COMPLETED(err);
}
else {
tempFile = path;
try {
Promise.resolve(action(tempFile)).then((result) => {
COMPLETED(null, result);
}).catch((e) => {
COMPLETED(e);
});
}
catch (e) {
COMPLETED(e);
}
}
function grepAsync(regex, text, callback){
var tmp = require('tmp');
tmp.tmpName(function _tempNameGenerated(err, path) {
if (err) throw err;
fs.writeFileSync(path, text);
var result = sh.grep(regex, path);
callback(result);
});
}
return new Promise(function(fulfill, reject) {
tmp.tmpName(options, function(err, filePath) {
if (err) {
reject(err);
} else {
fulfill(filePath);
}
});
});
};
return new Promise((resolve, reject) => {
const readStream = fs.createReadStream(filename);
readStream.on('error', reject);
const base = path.basename(filename, '.ipynb');
tmp.tmpName({ prefix: `${base}-Copy`, postfix: '.ipynb' }, (err, newFilename) => {
if (err) {
reject(err);
}
const writeStream = fs.createWriteStream(newFilename);
writeStream.on('error', reject);
readStream.pipe(writeStream);
writeStream.on('close', resolve(newFilename));
});
});
}