Windows safe filename regex

This commit is contained in:
Vladimir Carrer 2018-12-05 00:12:02 +01:00
parent b7a530e575
commit 904aa80fa1
2 changed files with 7 additions and 5 deletions

View file

@ -35,17 +35,19 @@ console.log(fullPage);
if (program.w && program.h) await page.setViewport({width: Number(program.w), height: Number(program.h)}) if (program.w && program.h) await page.setViewport({width: Number(program.w), height: Number(program.h)})
if (program.emulate) await page.emulate(devices[program.emulate]); if (program.emulate) await page.emulate(devices[program.emulate]);
await page.goto(urlvalue) await page.goto(urlvalue)
const title = await page.title()
const t = title.replace(/[/\\?%*:|"<>]/g, '-')
if (program.waitfor) await page.waitFor(Number(program.waitfor)) if (program.waitfor) await page.waitFor(Number(program.waitfor))
if (program.el) { if (program.el) {
const el = await page.$(program.el); const el = await page.$(program.el);
await el.screenshot({ await el.screenshot({
path: `${await page.title()} ${program.emulate} ${program.el} ${d.getTime()}.png` path: `${t} ${program.emulate} ${program.el} ${d.getTime()}.png`
}); });
} else { } else {
await page.screenshot({path: await page.title() + " " + program.emulate + " " + d.getTime() + '.png', fullPage: fullPage}) await page.screenshot({path: t + " " + program.emulate + " " + d.getTime() + '.png', fullPage: fullPage})
} }
await page.emulateMedia('screen') await page.emulateMedia('screen')
if (program.pdf) await page.pdf({ path: await page.title() + " " + program.emulate + " " + d.getTime() + '.pdf' }) if (program.pdf) await page.pdf({ path: t + " " + program.emulate + " " + d.getTime() + '.pdf' })
console.log(await page.title()) console.log(t)
await browser.close() await browser.close()
})() })()

View file

@ -1,6 +1,6 @@
{ {
"name": "screenshoteer", "name": "screenshoteer",
"version": "1.0.2", "version": "1.0.3",
"description": "Make screenshots and device emulations form your terminal", "description": "Make screenshots and device emulations form your terminal",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {