-
Notifications
You must be signed in to change notification settings - Fork 126
/
cli.js
executable file
·40 lines (34 loc) · 983 Bytes
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env node
'use strict';
const meow = require('meow');
const chalk = require('chalk');
const updateNotifier = require('update-notifier');
const psi = require('.');
const cli = meow(`
Usage
$ psi <url>
Options
--key Google API Key. By default the free tier is used
--strategy Strategy to use when analyzing the page: mobile|desktop
--format Output format: cli|json|tap
--locale Locale results should be generated in
--threshold Threshold score to pass the PageSpeed test
--links Adds link with more info about opportunities
Example
$ psi https://addyosmani.com --strategy=mobile
`);
updateNotifier({pkg: cli.pkg}).notify();
if (!cli.input[0]) {
console.error('Specify a URL');
process.exit(1);
}
psi.output(cli.input[0], cli.flags).then(() => {
process.exit();
}).catch(error => {
if (error.noStack) {
console.error(chalk.red(error.message));
process.exit(1);
} else {
throw error;
}
});