Use fs-extra in index.

This commit is contained in:
mmcwilliams 2019-10-31 00:57:54 -04:00
parent 5611ea338a
commit 69ccdc58c1
1 changed files with 8 additions and 8 deletions

View File

@ -2,7 +2,7 @@
const restify = require('restify') const restify = require('restify')
const log = require('./lib/log')('main') const log = require('./lib/log')('main')
const fs = require('fs') const { readFile } = require('fs-extra')
const { exec } = require('child_process') const { exec } = require('child_process')
const BLE = require('./lib/ble') const BLE = require('./lib/ble')
@ -584,13 +584,13 @@ function bRestart (obj, cb) {
} }
function index (req, res, next) { function index (req, res, next) {
fs.readFile(INDEXPATH, 'utf8', (err, data) => { let data
if (err) {
try {
data = await readFile(INDEXPATH, 'utf8')
} catch (err) {
return next(err) return next(err)
} }
res.end(data)
next()
})
} }
function init () { function init () {