mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +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
@@ -1,7 +1,5 @@
|
||||
exceptions:
|
||||
- id: warning-02
|
||||
repeatable: true
|
||||
condition:
|
||||
- condition:
|
||||
command:
|
||||
- '`'
|
||||
hints:
|
||||
|
||||
@@ -107,7 +107,7 @@ stages:
|
||||
pwd:
|
||||
- ^/home/commander/folder1$
|
||||
command:
|
||||
- ls
|
||||
- ^ls$
|
||||
responses:
|
||||
- content:
|
||||
- 你現在可以看到 `folder1` 資料夾中有兩的檔案,分別是 `file1.txt` 跟 `file2.txt`。
|
||||
|
||||
@@ -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