feat: load global exceptions

This commit is contained in:
Lin, Hung-Shin committed 2023-11-26 18:40:39 +08:00
1 parent 49fb5a6a61
commit 98a226f3ff
3 files changed
+12 -4

No files matched your search

+1 -3
View File
@@ -1,7 +1,5 @@
exceptions:
- id: warning-02
repeatable: true
condition:
- condition:
command:
- '`'
hints:
+1 -1
View File
@@ -107,7 +107,7 @@ stages:
pwd:
- ^/home/commander/folder1$
command:
- ls
- ^ls$
responses:
- content:
- 你現在可以看到 `folder1` 資料夾中有兩的檔案,分別是 `file1.txt` 跟 `file2.txt`。
+10
View File
@@ -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)
}