Use fs-extra in index.
This commit is contained in:
parent
5611ea338a
commit
69ccdc58c1
12
index.js
12
index.js
|
@ -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 () {
|
||||||
|
|
Loading…
Reference in New Issue