forked from nuxtlabs/vue-telescope-analyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvta.js
executable file
·40 lines (34 loc) · 1.08 KB
/
vta.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
#!/usr/bin/env node
const ora = require('ora')
const consola = require('consola')
const yargs = require('yargs')
yargs
.usage('$0 [url]', 'analyze an url', (yargs) => {
yargs.positional('url', {
describe: 'the url to analyze',
type: 'string'
})
}, async (argv) => {
if (!argv.url) {
consola.error('Please provide an url to analyze')
return yargs.showHelp()
}
const spinner = ora(`Detecting Vue on ${argv.url}`).start()
setTimeout(() => spinner.color = 'magenta', 2500)
setTimeout(() => spinner.color = 'blue', 5000)
setTimeout(() => spinner.color = 'yellow', 7500)
const hrstart = process.hrtime()
try {
const result = await require('..')(argv.url, { browserWSEndpoint: argv.browserWSEndpoint })
spinner.stop()
consola.log(result)
const hrend = process.hrtime(hrstart)
consola.info('Execution time (hr): %ds %dms', hrend[0], hrend[1] / 1000000)
process.exit(0)
} catch (err) {
consola.error(err.message)
if (err.body) consola.log(err.body)
process.exit(1)
}
})
.argv