Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
res.sendSafely(_.bind(function(cb) {
var urlPath = req.params[0].split('/');
if (urlPath.length > 1 && urlPath[0] == imagesDirName) {
var imageFileName = urlPath[1];
// var imageSize = urlPath[2];
// var imagePath = path.join(blog.contentPaths[0].path, imagesDirName,
// imageFileName);
var imageSize = null;//urlPath[2];
var imagePath = path.join(blog.contentPaths[0].path, imagesDirName,
urlPath.slice(1).join('/'));
if (!imageSize) {
cb(0, {path: imagePath});
} else {
var temp = require('temp');
var tempPath = temp.path({suffix: path.extname(imagePath)});
var options = {
srcPath: imagePath,
dstPath: tempPath
};
var m = /^\s*(\d*)x(\d*)\s*$/.exec(imageSize);
if (m) {
if (m[1]) {
options.width = parseInt(m[1]);
}
if (m[2]) {
options.height = parseInt(m[2]);
}
}
if (options.width && options.height) {
async function writeHtmlToTempFile(html?: string): Promise {
if (!html) {
return;
}
try {
const tempFile = temp.path({ prefix: 'sme-result-', suffix: '.html' });
fs.writeFileSync(tempFile, html);
const childProcess = await open(tempFile);
if (childProcess.stderr) {
// Catch error output from child process
childProcess.stderr.once('data', (error: Buffer) => {
logError({ code: 'CannotOpenTempFile', tempFile, error });
});
}
} catch (error) {
throw new AppError({ code: 'CannotCreateTempFile' }, error);
}
}
beforeEach(() => {
startingDir = process.cwd();
tempDir = path();
setupGitFlowTestRepo(tempDir);
});
_buildDiffFile(failureReport) {
const diffPath = temp.path({dir: this.diffDir, suffix: '.png'});
return Promise.resolve(failureReport.saveDiffTo(diffPath))
.thenReturn(diffPath);
}
function downloadI18NZip(url, callback) {
var tempName = temp.path({ suffix: '.zip' }),
tempStream = fs.createWriteStream(tempName),
req = request({
url: url
});
req.pipe(tempStream);
req.on('error', function (err) {
afs.exists(tempName) && fs.unlinkSync(tempName);
console.error('\n' + __('Failed to download zip file: %s', err.toString()) + '\n');
process.exit(1);
});
req.on('response', function (req) {
if (req.statusCode >= 400) {
console.error('\n' + __('Request failed with HTTP status code %s %s', req.statusCode, http.STATUS_CODES[req.statusCode] || '') + '\n');
function writeToHtml(html) {
const tempName = temp.path({ suffix: '.html' });
fs.writeFileSync(tempName, html);
open(tempName, { wait: false }).catch(error => {
console.error('Unable to open web browser. ' + error);
console.error(
'Either run with --html, --json or --tsv, or view HTML for the visualization at:'
);
console.error(tempName);
});
}
function comparePaths (config) {
config.comparePath = path.join(config.backstop, 'compare/output');
config.tempCompareConfigFileName = temp.path({ suffix: '.json' });
}
function getInstOutputFile(filePath) {
if (filePath) {
return path.resolve(filePath);
} else {
return temp.path({suffix: '.js'});
}
}
public async getDeviceFileContent(device: Mobile.IDevice, deviceFilePath: string, projectData: IProjectData): Promise {
temp.track();
const uniqueFilePath = temp.path({ suffix: ".tmp" });
const platform = device.deviceInfo.platform.toLowerCase();
try {
await device.fileSystem.getFile(deviceFilePath, projectData.projectIdentifiers[platform], uniqueFilePath);
} catch (e) {
return null;
}
if (this.$fs.exists(uniqueFilePath)) {
const text = this.$fs.readText(uniqueFilePath);
shell.rm(uniqueFilePath);
return text;
}
return null;
}
}
TorrentFile.prototype.makeFile = function() {
this.path = temp.path({dir: "tmp", suffix: this.extension});
if (this.file) {
this.writeStream = fs.createWriteStream(this.path);
this.readStream.pipe(this.writeStream);
}
};
TorrentFile.prototype.cleanup = function() {