Skip to content

Commit

Permalink
Updates engines. Switches to promises (patch)
Browse files Browse the repository at this point in the history
  • Loading branch information
zrrrzzt committed Jul 4, 2018
1 parent d8a547d commit 27a5289
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# IDE
.idea
.vscode

# OS X
.DS_Store
Expand Down Expand Up @@ -32,3 +33,9 @@ build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

# Env
.env

# Lock
package-lock.json
11 changes: 9 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
language: node_js
node_js:
- "6"
- "8"
after_success:
- npm run coveralls
- npm run coveralls
deploy:
provider: npm
email: $NPM_EMAIL
api_key: $NPM_TOKEN
on:
tags: true
branch: master
12 changes: 5 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env node
'use strict'

var pagespeed = require('gpagespeed')
var getHelpText = require('./lib/getHelpText')
Expand Down Expand Up @@ -57,11 +56,10 @@ if (argv.dryrun) {
process.exit(0)
}

pagespeed(options, function (error, data) {
if (error) {
pagespeed(options)
.then(data => {
console.log(JSON.stringify(data))
}).catch(error => {
console.error(error)
process.exit(1)
} else {
console.log(JSON.stringify(data))
}
})
})
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
"gpagespeed": "index.js"
},
"engines": {
"node": ">=6.10.2"
"node": ">=8.11.3"
},
"scripts": {
"test": "standard && tap --reporter=spec test/**/*.js",
"coverage": "tap test/**/*.js --coverage",
"coveralls": "tap --cov --coverage-report=lcov test/**/*.js && cat coverage/lcov.info | coveralls",
"setup": "npm install"
"standard-fix": "standard --fix",
"refresh": "rm -rf node_modules && rm package-lock.json && npm install"
},
"keywords": [
"cli",
Expand Down
4 changes: 2 additions & 2 deletions test/lib/cli-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ tap.test('It sets url if supplied', function testUrl (test) {

tap.test('It returns error on invalid url', function testError (test) {
exec('./index.js', ['http://pysje'], function testWithError (error, stdout, stderr) {
test.ok(error, 'Error ok')
test.ok(error.toString().trim(), 'Error ok')
test.end()
})
})

tap.test('It returns data if url supplied', function testData (test) {
exec('./index.js', ['http://www.google.com'], function testWithData (error, stdout, stderr) {
exec('./index.js', ['https://www.google.com'], function testWithData (error, stdout, stderr) {
if (error) {
throw error
}
Expand Down

0 comments on commit 27a5289

Please sign in to comment.