mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
fix: remove order in game schema
This commit is contained in:
1 parent
f864cecfa4
commit
b4a37f7606
7 files changed
+45
-34
No files matched your search
+1
-1
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"watch": ["src", "swagger.yaml"],
|
||||
"watch": ["src", "swagger.yaml", "../quests"],
|
||||
"ext": "js,yaml"
|
||||
}
|
||||
+29
-25
@@ -10,35 +10,39 @@ export default async function loadAndUpdateQuests() {
|
||||
const questNames = await fs.readdir(questDirectory)
|
||||
|
||||
const quests = Promise.all(
|
||||
questNames.map(async (id) => {
|
||||
// Check if id is directory
|
||||
const stat = await fs.stat(path.join(questDirectory, id))
|
||||
if (!stat.isDirectory()) {
|
||||
return null
|
||||
}
|
||||
const fullPath = path.join(questDirectory, id, 'game.yml')
|
||||
questNames
|
||||
.filter((name) => !name.startsWith('.'))
|
||||
.map(async (id) => {
|
||||
// Check if id is directory
|
||||
const stat = await fs.stat(path.join(questDirectory, id))
|
||||
if (!stat.isDirectory()) {
|
||||
return null
|
||||
}
|
||||
const fullPath = path.join(questDirectory, id, 'game.yml')
|
||||
|
||||
try {
|
||||
// Read and parse the README.md file.
|
||||
const body = await fs.readFile(fullPath, 'utf-8')
|
||||
try {
|
||||
// Read and parse the README.md file.
|
||||
const body = await fs.readFile(fullPath, 'utf-8')
|
||||
|
||||
const quest = yaml.parse(body)
|
||||
const quest = yaml.parse(body, {
|
||||
merge: true,
|
||||
})
|
||||
|
||||
return Quest.findByIdAndUpdate(
|
||||
id,
|
||||
{
|
||||
return Quest.findByIdAndUpdate(
|
||||
id,
|
||||
...quest,
|
||||
},
|
||||
{
|
||||
upsert: true,
|
||||
}
|
||||
)
|
||||
} catch (error) {
|
||||
console.error(`Error parsing quest ${id}:`, error)
|
||||
throw error
|
||||
}
|
||||
})
|
||||
{
|
||||
id,
|
||||
...quest,
|
||||
},
|
||||
{
|
||||
upsert: true,
|
||||
}
|
||||
)
|
||||
} catch (error) {
|
||||
console.error(`Error parsing quest ${id}:`, error)
|
||||
throw error
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
return quests
|
||||
|
||||
Reference in new issue
Block a user