Skip to content
代码片段 群组 项目
提交 a8d73e6d 编辑于 作者: Timotej Ecimovic's avatar Timotej Ecimovic
浏览文件

Continue the cleanup.

上级 a0b977c4
No related branches found
No related tags found
无相关合并请求
...@@ -30,17 +30,17 @@ const importJson = require('./import-json.js') ...@@ -30,17 +30,17 @@ const importJson = require('./import-json.js')
* @param {*} filePath * @param {*} filePath
* @returns Promise of file reading. * @returns Promise of file reading.
*/ */
function readDataFromFile(filePath) { async function readDataFromFile(filePath) {
return fsp.readFile(filePath).then((data) => { var data = await fsp.readFile(filePath)
var stringData = data.toString().trim()
if (stringData.startsWith('{')) { var stringData = data.toString().trim()
return importJson.readJsonData(filePath, data) if (stringData.startsWith('{')) {
} else if (stringData.startsWith('#ISD')) { return importJson.readJsonData(filePath, data)
return importIsc.readIscData(filePath, data) } else if (stringData.startsWith('#ISD')) {
} else { return importIsc.readIscData(filePath, data)
throw 'Invalid file format. Only .zap JSON files and ISC file format are supported.' } else {
} throw 'Invalid file format. Only .zap JSON files and ISC file format are supported.'
}) }
} }
/** /**
...@@ -51,10 +51,9 @@ function readDataFromFile(filePath) { ...@@ -51,10 +51,9 @@ function readDataFromFile(filePath) {
* @param {*} filePath * @param {*} filePath
* @returns a promise that resolves with the session Id of the written data. * @returns a promise that resolves with the session Id of the written data.
*/ */
function importDataFromFile(db, filePath, sessionId = null) { async function importDataFromFile(db, filePath, sessionId = null) {
return readDataFromFile(filePath).then((state) => var state = await readDataFromFile(filePath)
state.loader(db, state, sessionId) return state.loader(db, state, sessionId)
)
} }
// exports // exports
exports.readDataFromFile = readDataFromFile exports.readDataFromFile = readDataFromFile
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册