-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·37 lines (33 loc) · 822 Bytes
/
cli.js
File metadata and controls
executable file
·37 lines (33 loc) · 822 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
#!/usr/bin/env node
"use strict";
const meow = require("meow");
const chalk = require("chalk");
const updateNotifier = require("update-notifier");
const pagespeedNow = require(".");
const cli = meow(`
Usage
$ pagespeed-now <port|folder>
Options
--strategy Strategy to use when analyzing the page: mobile|desktop (default: mobile)
Examples
$ pagespeed-now 3000 --strategy=mobile
$ pagespeed-now _site
$ pagespeed-now .
`);
updateNotifier({ pkg: cli.pkg }).notify();
if (!cli.input[0]) {
console.error("Specify a port or folder");
process.exit(1);
}
pagespeedNow(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;
}
});