Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#!/usr/bin/env node
const url = require('url')
const path = require('path')
const program = require('commander')
const chalk = require('chalk')
const puppeteer = require('puppeteer')
const devices = require('puppeteer/DeviceDescriptors')
const pagesizes = require('./page-sizes')
const { version } = require('./package.json')
const devicesNames = devices.reduce((ret, device) => {
ret[device.name] = true
return ret
}, {})
const types = ['png', 'jpg', 'jpeg', 'pdf']
const validFileType = type => types.indexOf(type) >= 0
program
.version(version)
.usage('[options] ')
.option('-d, --device ', 'use device')
.option('--no-fullpage', 'no fullpage')
.option('-f, --file ', 'output file name')
.option('-t, --type ', 'output file type: png, jpg, jpeg or pdf', 'png')
.option('-s, --page-size ', 'pdf page size, default A4', 'A4')
.option('-v, --viewport ', 'viewport, default 1440x900', '1440x900')