forked from GoogleChromeLabs/psi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·41 lines (35 loc) · 1010 Bytes
/
cli.js
File metadata and controls
executable file
·41 lines (35 loc) · 1010 Bytes
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
41
#!/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-v4 <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
--optimized Get the URL of optimized resources
--download Download optimized resources
Example
$ psi-v4 todomvc.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(err => {
if (err.noStack) {
console.error(chalk.red(err.message));
process.exit(1);
} else {
throw err;
}
});