paparazzi-cli
Advanced tools
Comparing version 0.3.0 to 0.3.1
29
index.js
@@ -5,2 +5,3 @@ #!/usr/bin/env node | ||
const URL = require('url').URL; | ||
const lib = require("./lib"); | ||
@@ -69,4 +70,4 @@ let browser; | ||
try { | ||
await screenshot(page, q.pop(), args); | ||
await addLinks(page, q, allowedHosts, args); | ||
await lib.screenshot(page, q.pop(), args); | ||
await lib.addLinks(page, q, allowedHosts, args); | ||
} catch (e) { | ||
@@ -81,26 +82,2 @@ throw e; | ||
async function screenshot(page, url, args) { | ||
console.log(`Snapping ${url}`); | ||
let fileName = url.replace(/\//g, '_'); | ||
await page.goto(url); | ||
await page.waitFor(args.delay); | ||
await page.screenshot({ path: `${args.output}/${fileName}.png`, type: 'png', fullPage: args.fullPage }); | ||
} | ||
async function addLinks(page, q, allowedHosts, args) { | ||
//Get all the links on the page, ignore empty href. | ||
let links = await page.$$eval('a', al => { return al.map(a => a.href).filter(a => a)}); | ||
for (let l of links) { | ||
try { | ||
let ul = new URL(l); | ||
if (args.allowAllHosts || allowedHosts.includes(ul.hostname.stripPrefix('www.').trim())) { | ||
q.push(l); | ||
} | ||
} catch (e) { | ||
console.log(`Could not parse ${l}, skipping.`) | ||
} | ||
} | ||
} | ||
let argv = require('yargs') | ||
@@ -107,0 +84,0 @@ .usage('Usage: $0 [options] <URL1> [<URL2> ...]') |
{ | ||
"name": "paparazzi-cli", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "CLI tool to snap all the angles of your website", | ||
@@ -14,2 +14,5 @@ "main": "index.js", | ||
], | ||
"scripts": { | ||
"test": "nyc -x **/*.spec.js mocha **/*.spec.js" | ||
}, | ||
"dependencies": { | ||
@@ -21,3 +24,7 @@ "puppeteer": "^1.14.0", | ||
"paparazzi": "./index.js" | ||
}, | ||
"devDependencies": { | ||
"chai": "^4.2.0", | ||
"sinon": "^7.3.1" | ||
} | ||
} |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
59434
8
150
1
2