mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: load global exceptions
This commit is contained in:
1 parent
49fb5a6a61
commit
98a226f3ff
3 files changed
+12
-4
No files matched your search
@@ -32,8 +32,16 @@ async function mapQuests(callback) {
|
||||
)
|
||||
}
|
||||
|
||||
async function loadGlobalExceptions() {
|
||||
const exceptionsPath = path.join(questDirectory, 'exceptions.yml')
|
||||
const body = await fs.readFile(exceptionsPath, 'utf-8')
|
||||
return yaml.parse(body)
|
||||
}
|
||||
|
||||
export async function loadAndUpdateQuests() {
|
||||
await Quest.deleteMany({})
|
||||
const { exceptions } = await loadGlobalExceptions()
|
||||
console.log(exceptions)
|
||||
return mapQuests(async (id, questPath) => {
|
||||
const files = await fs.readdir(questPath)
|
||||
if (!files.includes('game.yml')) {
|
||||
@@ -53,8 +61,10 @@ export async function loadAndUpdateQuests() {
|
||||
image,
|
||||
...questData,
|
||||
})
|
||||
quest.exceptions.push(...exceptions)
|
||||
await quest.save()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
logger.error(`Error parsing quest`, { id, error })
|
||||
throw new QuestValidationError(`Error parsing quest`, id, error)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user