mirror of
https://github.com/barkeser2002/node-minecraft-data.git
synced 2026-09-25 13:26:14 +03:00
19 lines
486 B
JavaScript
19 lines
486 B
JavaScript
const fs = require('fs')
|
|
const path = require('path')
|
|
|
|
let cache = null
|
|
const archivePath = path.join(__dirname, '../minecraft-data.zip')
|
|
|
|
module.exports = (fileName) => {
|
|
if (cache !== null || fs.existsSync(archivePath)) {
|
|
if (cache === null) {
|
|
const AdmZip = require('adm-zip')
|
|
cache = new AdmZip(archivePath)
|
|
}
|
|
fileName = fileName.split('/').slice(1).join('/')
|
|
return JSON.parse(cache.readAsText(fileName))
|
|
} else {
|
|
return require(fileName)
|
|
}
|
|
}
|