diff --git a/quests/exceptions.yml b/quests/exceptions.yml index 872c30b..6ffe5f5 100644 --- a/quests/exceptions.yml +++ b/quests/exceptions.yml @@ -1,7 +1,5 @@ exceptions: - - id: warning-02 - repeatable: true - condition: + - condition: command: - '`' hints: diff --git a/quests/explore/game.yml b/quests/explore/game.yml index 977e1b2..5aa292e 100644 --- a/quests/explore/game.yml +++ b/quests/explore/game.yml @@ -107,7 +107,7 @@ stages: pwd: - ^/home/commander/folder1$ command: - - ls + - ^ls$ responses: - content: - 你現在可以看到 `folder1` 資料夾中有兩的檔案,分別是 `file1.txt` 跟 `file2.txt`。 diff --git a/server/src/utils/quest.js b/server/src/utils/quest.js index 900f51c..dc96f73 100644 --- a/server/src/utils/quest.js +++ b/server/src/utils/quest.js @@ -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) }