gpagespeed
Advanced tools
Comparing version 0.0.5 to 0.0.6
10
cli.js
@@ -15,7 +15,7 @@ #!/usr/bin/env node | ||
console.log('Usage:'); | ||
console.log(' $ gpagespeed --url=<url> --key=<key>'); | ||
console.log(' $ gpagespeed <url> --key=<key>'); | ||
console.log(''); | ||
console.log('Optional, supply other arguments.'); | ||
console.log('See https://developers.google.com/speed/docs/insights/v1/getting_started for description'); | ||
console.log(' $ gpagespeed --url=<url> --key=<key> --callback=<callback> --prettyprint=<true> --userIp=<userIp> --locale=<locale> --strategy=<desktop|mobile>'); | ||
console.log(' $ gpagespeed <url> --key=<key> --callback=<callback> --prettyprint=<true> --userIp=<userIp> --locale=<locale> --strategy=<desktop|mobile>'); | ||
} | ||
@@ -33,3 +33,7 @@ | ||
if(!argv.url || (!argv.key && !argv.nokey)){ | ||
if (query.indexOf('http') !== -1) { | ||
opts.url = argv._[0]; | ||
} | ||
if(!opts.url || (!argv.key && !argv.nokey)){ | ||
printHelp(); | ||
@@ -36,0 +40,0 @@ return; |
10
index.js
var request = require('request') | ||
, pagespeedUrl = 'https://www.googleapis.com/pagespeedonline/v1/runPagespeed'; | ||
, validUrl = require('valid-url') | ||
, pagespeedUrl = 'https://www.googleapis.com/pagespeedonline/v1/runPagespeed' | ||
; | ||
module.exports = function(opts, callback){ | ||
if(!opts.key && !opts.nokey){ | ||
return callback(new Error('Missing required param: key'), null); | ||
} | ||
if(!opts.url){ | ||
@@ -12,2 +16,6 @@ return callback(new Error('Missing required param: url'), null); | ||
if(opts.url && !validUrl.isWebUri(opts.url)){ | ||
return callback(new Error('Invalid url'), null); | ||
} | ||
request(pagespeedUrl,{qs:opts}, function(error, res, body){ | ||
@@ -14,0 +22,0 @@ if(error){ |
{ | ||
"name": "gpagespeed", | ||
"description": "Analyze a webpage with Google PageSpeed", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"author": { | ||
"name": "Geir Gåsodden", | ||
"email": "geir.gasodden@pythonia.no" | ||
"email": "geir.gasodden@pythonia.no", | ||
"url": "https://github.com/zrrrzzt" | ||
}, | ||
@@ -17,3 +18,3 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "mocha test/test.js --timeout 10s" | ||
"test": "mocha --reporter spec test/*.js --timeout 10s" | ||
}, | ||
@@ -32,8 +33,9 @@ "files": [ | ||
"dependencies": { | ||
"request": "^2.34.0", | ||
"minimist": "0.0.8" | ||
"minimist": "^0.1.0", | ||
"request": "^2.36.0", | ||
"valid-url": "^1.0.9" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^1.18.2" | ||
"mocha": "^1.20.0" | ||
} | ||
} |
@@ -53,3 +53,3 @@ #gpagespeed [![Build Status](https://travis-ci.org/zrrrzzt/gpagespeed.svg?branch=master)](https://travis-ci.org/zrrrzzt/gpagespeed) | ||
``` | ||
$ gpagespeed --url=<url> --key=<key> | ||
$ gpagespeed <url> --key=<key> | ||
``` | ||
@@ -60,3 +60,3 @@ | ||
``` | ||
$ gpagespeed --url=<url> --key=<key> --callback=<callback> --prettyprint=<true> --userIp=<userIp> --locale=<locale> --strategy=<desktop|mobile> | ||
$ gpagespeed <url> --key=<key> --callback=<callback> --prettyprint=<true> --userIp=<userIp> --locale=<locale> --strategy=<desktop|mobile> | ||
``` | ||
@@ -63,0 +63,0 @@ |
4695
83
3
+ Addedvalid-url@^1.0.9
+ Addedminimist@0.1.0(transitive)
+ Addedvalid-url@1.0.9(transitive)
- Removedminimist@0.0.8(transitive)
Updatedminimist@^0.1.0
Updatedrequest@^2.36.0