christopherwk210 / site-scan

CLI for capturing website screenshots, powered by puppeteer.
MIT License
136 stars 13 forks source link

修改 -j 无法输出jpg格式 #11

Open ifeiwu opened 5 years ago

ifeiwu commented 5 years ago

lib/site-scan.js

// Take the screenshot try { await page.screenshot({ path: ${options.path}${fileName}.png, fullPage: options.full, omitBackground: options.transparent, type: options.jpeg ? 'jpeg' : 'png', quality: options.quality });
} catch(e) { console.log(chalk{red • Error taking screenshot of ${url}. Skipping...}); return; }

console.log(chalk{green ✔ Screenshot saved to ${fileName}.png});

改为

let image_type = options.jpeg ? 'jpeg' : 'png';

// Take the screenshot try { await page.screenshot({ path: ${options.path}${fileName}.${image_type}, fullPage: options.full, omitBackground: options.transparent, type: image_type, quality: options.quality });
} catch(e) { console.log(chalk{red • Error taking screenshot of ${url}. Skipping...}); return; }

console.log(chalk{green ✔ Screenshot saved to ${fileName}.${image_type}});