mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 21:27:47 +00:00
22 lines
560 B
JavaScript
22 lines
560 B
JavaScript
import fs from 'fs';
|
|
import { mapResourcesPath } from '../lib/path.js';
|
|
export function checkFolderExistAndCreate(folderPath) {
|
|
if (!fs.existsSync(folderPath)) {
|
|
fs.mkdirSync(folderPath, { recursive: true });
|
|
}
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param {string} fileName 名称(不包含后缀)
|
|
* @returns {object | null}
|
|
*/
|
|
export function getMapData(fileName) {
|
|
const mapDataPath = `${mapResourcesPath}/${fileName}.json`;
|
|
try {
|
|
const mapData = fs.readFileSync(mapDataPath, 'utf-8');
|
|
return JSON.parse(mapData);
|
|
} catch (error) {
|
|
return null;
|
|
}
|
|
}
|