Make sure the path is correct (#2341)

Co-authored-by: ligi <ligi@ligi.de>
This commit is contained in:
Jack 2023-03-16 15:56:44 +08:00 committed by GitHub
parent 76d248b68e
commit 4bbf72ec3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,10 @@ const Ajv = require("ajv")
const ajv = new Ajv() const ajv = new Ajv()
const schema = require("./schema/chainSchema.json") const schema = require("./schema/chainSchema.json")
const { exit } = require("process") const { exit } = require("process")
const chainFiles = fs.readdirSync("../_data/chains/") const path = require('path')
const resolve = (_path) => path.resolve(__dirname, _path)
const chainFiles = fs.readdirSync(resolve("../_data/chains/"))
// https://chainagnostic.org/CAIPs/caip-2 // https://chainagnostic.org/CAIPs/caip-2
const parseChainId = (chainId) => const parseChainId = (chainId) =>
@ -13,7 +16,7 @@ const parseChainId = (chainId) =>
const filesWithErrors = [] const filesWithErrors = []
for (const chainFile of chainFiles) { for (const chainFile of chainFiles) {
const fileLocation = `../_data/chains/${chainFile}` const fileLocation = resolve(`../_data/chains/${chainFile}`)
const fileData = fs.readFileSync(fileLocation, "utf8") const fileData = fs.readFileSync(fileLocation, "utf8")
const fileDataJson = JSON.parse(fileData) const fileDataJson = JSON.parse(fileData)
const fileName = chainFile.split(".")[0] const fileName = chainFile.split(".")[0]