Skip to content

Commit

Permalink
Meta tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Mar 14, 2019
1 parent 01e5425 commit 959c657
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
* text=auto
*.js text eol=lf
* text=auto eol=lf
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language: node_js
node_js:
- '10'
- '8'
- '6'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ $ psi --help
--download Download optimized resources
Example
$ psi todomvc.com --strategy=mobile
$ psi https://addyosmani.com --strategy=mobile
```


Expand Down
2 changes: 1 addition & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const cli = meow(`
--download Download optimized resources
Example
$ psi todomvc.com --strategy=mobile
$ psi https://addyosmani.com --strategy=mobile
`);

updateNotifier({pkg: cli.pkg}).notify();
Expand Down
16 changes: 8 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ const output = require('./lib/output');

const pagespeed = pify(googleapis.google.pagespeedonline('v4').pagespeedapi);

function handleOpts(url, opts) {
opts = Object.assign({strategy: 'mobile'}, opts);
opts.nokey = opts.key === undefined;
opts.url = prependHttp(url);
return opts;
function handleOpts(url, options) {
options = Object.assign({strategy: 'mobile'}, options);
options.nokey = options.key === undefined;
options.url = prependHttp(url);
return options;
}

const psi = (url, opts) => Promise.resolve().then(() => {
const psi = (url, options) => Promise.resolve().then(() => {
if (!url) {
throw new Error('URL required');
}

return pagespeed.runpagespeed(handleOpts(url, opts));
return pagespeed.runpagespeed(handleOpts(url, options));
});

module.exports = psi;

module.exports.output = (url, opts) => psi(url, opts).then(data => output(handleOpts(url, opts), data.data));
module.exports.output = (url, options) => psi(url, options).then(data => output(handleOpts(url, options), data.data));
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('Formatting', () => {
this.formattedOutput = '';

console.log = content => {
this.formattedOutput += content + '\n';
this.formattedOutput += `${content}\n`;
this.log(content);
};
});
Expand Down

0 comments on commit 959c657

Please sign in to comment.