Add check chtext element and ids,fix quest problem

This commit is contained in:
Annie committed 2023-11-21 12:56:15 +08:00
1 parent 9da23b5dc1
commit 869f01a62b
11 files changed
+90 -78

No files matched your search

+21 -7
View File
@@ -79,6 +79,16 @@ export async function deleteContainer(id) {
await container.remove()
}
function parseJSONOutput(data) {
const { stream, error } = JSON.parse(data.toString())
if (stream) {
console.log(stream)
}
if (error) {
throw error
}
}
export function buildQuestImage(questPath, questId) {
return new Promise((resolve, reject) => {
engine.buildImage(
@@ -97,13 +107,17 @@ export function buildQuestImage(questPath, questId) {
}
response.on('data', (data) => {
// Process the data (this could be Docker build output)
const { stream, error } = JSON.parse(data.toString())
if (stream) {
console.log(stream)
}
if (error) {
console.error(error)
reject(error)
try {
data
.toString()
.split('\n')
.map((line) => line.trim())
.filter((line) => line !== '')
.forEach((line) => {
parseJSONOutput(line.trim())
})
} catch (err) {
reject(err)
}
})