-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbin.js
More file actions
36 lines (30 loc) · 938 Bytes
/
bin.js
File metadata and controls
36 lines (30 loc) · 938 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
#! /usr/bin/env node
const args = require('minimist')(process.argv)
const { resolve, dirname } = require('path')
const fs = require('fs')
const Config = require('./config')
const Upload = require('./upload')
const logger = require('./logger')
const statsFilePath = resolve(args['stats'])
const outputPath = args['output-path'] || dirname(statsFilePath)
let stats
try {
logger(`retrieving stats from ${statsFilePath}`)
stats = JSON.parse(fs.readFileSync(statsFilePath, 'utf8'))
} catch (err) {
logger('there was a problem reading your stats file.')
console.error(err)
process.exit(1)
}
const config = new Config({ upload: true, fail_build: true })
const upload = new Upload(config)
upload.process(stats, outputPath)
.then(() => {
logger('stats uploaded successfully')
process.exit(0)
})
.catch((err) => {
logger('there was a problem uploading your stats.')
console.error(err)
process.exit(1)
})