Fix Build Quests Error (#94)

#92
This commit is contained in:
Lin, Hung-Shin authored and GitHub committed 2024-01-13 20:18:22 +08:00
commit 21c1a4d11c
2 files changed
+26 -25

No files matched your search

-1
View File
@@ -17,7 +17,6 @@ buildImages()
.then((result) => {
logger.info(result)
logger.info('Done!')
process.exit(0)
})
.catch((err) => {
logger.error(err)
+26 -24
View File
@@ -109,31 +109,33 @@ export function buildQuestImage(questPath, questId) {
if (err) {
reject(err)
}
response.on('data', (data) => {
// Process the data (this could be Docker build output)
try {
data
.toString()
.split('\n')
.map((line) => line.trim())
.filter((line) => line !== '')
.forEach((line) => {
parseJSONOutput(line)
})
} catch (error) {
if (response) {
response.on('data', (data) => {
// Process the data (this could be Docker build output)
try {
data
.toString()
.split('\n')
.map((line) => line.trim())
.filter((line) => line !== '')
.forEach((line) => {
parseJSONOutput(line)
})
} catch (error) {
reject(error)
}
})
response.on('end', () => {
logger.info(`Build completed for ${questId}`)
resolve(questId)
})
response.on('error', (error) => {
logger.error(`Build failed for ${questId}:`, error)
reject(error)
}
})
response.on('end', () => {
logger.info(`Build completed for ${questId}`)
resolve(questId)
})
response.on('error', (error) => {
logger.error(`Build failed for ${questId}:`, error)
reject(error)
})
})
}
}
)
})