mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 11:30: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:
|
exceptions:
|
||||||
- id: warning-02
|
- condition:
|
||||||
repeatable: true
|
|
||||||
condition:
|
|
||||||
command:
|
command:
|
||||||
- '`'
|
- '`'
|
||||||
hints:
|
hints:
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ stages:
|
|||||||
pwd:
|
pwd:
|
||||||
- ^/home/commander/folder1$
|
- ^/home/commander/folder1$
|
||||||
command:
|
command:
|
||||||
- ls
|
- ^ls$
|
||||||
responses:
|
responses:
|
||||||
- content:
|
- content:
|
||||||
- 你現在可以看到 `folder1` 資料夾中有兩的檔案,分別是 `file1.txt` 跟 `file2.txt`。
|
- 你現在可以看到 `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() {
|
export async function loadAndUpdateQuests() {
|
||||||
await Quest.deleteMany({})
|
await Quest.deleteMany({})
|
||||||
|
const { exceptions } = await loadGlobalExceptions()
|
||||||
|
console.log(exceptions)
|
||||||
return mapQuests(async (id, questPath) => {
|
return mapQuests(async (id, questPath) => {
|
||||||
const files = await fs.readdir(questPath)
|
const files = await fs.readdir(questPath)
|
||||||
if (!files.includes('game.yml')) {
|
if (!files.includes('game.yml')) {
|
||||||
@@ -53,8 +61,10 @@ export async function loadAndUpdateQuests() {
|
|||||||
image,
|
image,
|
||||||
...questData,
|
...questData,
|
||||||
})
|
})
|
||||||
|
quest.exceptions.push(...exceptions)
|
||||||
await quest.save()
|
await quest.save()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
logger.error(`Error parsing quest`, { id, error })
|
logger.error(`Error parsing quest`, { id, error })
|
||||||
throw new QuestValidationError(`Error parsing quest`, id, error)
|
throw new QuestValidationError(`Error parsing quest`, id, error)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user