зеркало из https://github.com/github/lightcrawler.git
Pipe stderr and log parse errors
This commit is contained in:
Родитель
403f997e15
Коммит
3c929304f7
10
index.js
10
index.js
|
@ -59,13 +59,21 @@ function runLighthouse (url, callback) {
|
|||
const lighthouse = ChildProcess.spawn(lighthousePath, args)
|
||||
|
||||
let output = ''
|
||||
lighthouse.stderr.pipe(process.stderr)
|
||||
lighthouse.stdout.on('data', (data) => {
|
||||
output += data
|
||||
})
|
||||
lighthouse.once('close', () => {
|
||||
let errorCount = 0
|
||||
|
||||
const report = JSON.parse(output)
|
||||
let report
|
||||
try {
|
||||
report = JSON.parse(output)
|
||||
} catch (parseError) {
|
||||
console.error(`Parsing JSON report output failed: ${output}`)
|
||||
callback(1)
|
||||
return
|
||||
}
|
||||
|
||||
report.reportCategories.forEach((category) => {
|
||||
category.audits.forEach((audit) => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче