Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
paths('.tmp', 'pdf', filename).then(filepath => {
if (filepath.endsWith('.pdf')) {
got.stream(opts.url)
.pipe(fs.createWriteStream(filepath));
}
if (filepath.endsWith('.zip')) {
got.stream(opts.url)
.pipe(unzip.Extract({path: path.dirname(filepath)})); // eslint-disable-line new-cap
}
});
}
const server = app.listen(8080, () => {
console.log('server started');
got.stream(`http://localhost:8080${testPath}`).pipe(process.stdout);
setTimeout(() => {
listTraces(testPath).then(verifyTraces);
}, WRITE_CONSISTENCY_DELAY_MS);
});
zipName = `${version.version}-linux-${program.arch}.zip`.slice(1);
} else {
console.error('Platform not supported');
process.exit(1);
}
const downloadUrl = `https://github.com/iteufel/nwjs-ffmpeg-prebuilt/releases/download/${version.version.slice(1)}/${zipName}`;
if (program.getDownloadUrl) {
process.stdout.write(downloadUrl);
process.exit(0);
}
await fs.ensureDir(outDir);
if (program.download) {
console.log(`Downloading NW.js ${version.version} - FFmpeg - (Chromium ${chromiumVersion})`);
await pipeline(
got.stream(downloadUrl),
fs.createWriteStream(path.join(outDir, zipName))
);
return;
}
console.log(`Building NW.js ${version.version} - FFmpeg - (Chromium ${chromiumVersion})`);
await fs.ensureDir('./build');
if (program.clean) {
console.log('Cleaning build Directory');
await fs.emptyDir('./build');
}
process.chdir('./build');
if (!(await fs.pathExists('./depot_tools'))) {
await execAsync('git', 'clone', 'https://chromium.googlesource.com/chromium/tools/depot_tools.git');
}
if (platform === 'win32' || platform === 'win') {
process.env.DEPOT_TOOLS_WIN_TOOLCHAIN = '0';
let tempDir;
try {
tempDir = await createTempDir();
const targetUpdatePath = join(tempDir, fileName);
const targetSignaturePath = join(tempDir, getSignatureFileName(fileName));
validatePath(tempDir, targetUpdatePath);
validatePath(tempDir, targetSignaturePath);
logger.info(`downloadUpdate: Downloading ${signatureUrl}`);
const { body } = await get(signatureUrl, getGotOptions());
await writeFile(targetSignaturePath, body);
logger.info(`downloadUpdate: Downloading ${updateFileUrl}`);
const downloadStream = stream(updateFileUrl, getGotOptions());
const writeStream = createWriteStream(targetUpdatePath);
await new Promise((resolve, reject) => {
downloadStream.on('error', error => {
reject(error);
});
downloadStream.on('end', () => {
resolve();
});
writeStream.on('error', error => {
reject(error);
});
downloadStream.pipe(writeStream);
});
return await new Promise((resolve, reject) => {
const downloadStream = got.stream(url, options);
downloadStream.pipe(writeStream);
const bar = new ProgressBar(
"downloading [:bar] :percent of :size Mb :etas",
{
total: 100
}
);
downloadStream.on("error", reject);
downloadStream.on("downloadProgress", progress => {
bar.total = progress.total;
bar.curr = progress.transferred;
bar.tick(0, { size: (progress.total / 1024 / 1024).toFixed(1) });
});
writeStream.on("error", reject);
writeStream.on("close", () => resolve());
});
function download(next) {
var fileStream = fs.createWriteStream(next.cachePath);
var error = null;
fileStream.on('error', function (err) {
error = err;
next.logger.error('error downloading:');
next.logger.error(err);
});
fileStream.on('finish', function () {
if(error) return next.callback(error);
checkCache(next);
});
got.stream(next.url).pipe(fileStream);
}
export async function parseFeed (feedUrl, faviconUrl = null) {
let feed
const feeditem = {
meta: '',
posts: []
}
try {
feed = await parser.parseURL(feedUrl)
} catch (e) {
const stream = await got.stream(feedUrl, { retries: 0 })
feed = await parseFeedParser(stream)
}
feeditem.meta = {
link: feed.link,
xmlurl: feed.feedUrl ? feed.feedUrl : feedUrl,
favicon: typeof faviconUrl !== 'undefined' ? faviconUrl : null,
description: feed.description ? feed.description : null,
title: feed.title
}
feeditem.posts = feed.items
const response = await ParseFeedPost(feeditem)
return response
}
getFile(id) {
return got.stream(`${API_FILE + this.token}/${id}`);
}
}