30 lines
1.2 KiB
JavaScript
30 lines
1.2 KiB
JavaScript
|
"use strict";
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
exports.SaveProject = void 0;
|
||
|
const fs = require("fs");
|
||
|
const path = require("node:path");
|
||
|
class SaveProject {
|
||
|
static saveProject(projectDir, storageModels) {
|
||
|
const directoryPath = 'testModel/';
|
||
|
if (!fs.existsSync(directoryPath)) {
|
||
|
fs.mkdirSync(directoryPath, { recursive: true });
|
||
|
}
|
||
|
storageModels.forEach(storageModel => {
|
||
|
const modelDir = path.join(directoryPath, storageModel.storageDir);
|
||
|
if (!fs.existsSync(modelDir)) {
|
||
|
fs.mkdirSync(modelDir, { recursive: true });
|
||
|
}
|
||
|
const filePath = path.join(directoryPath, storageModel.storageDir, storageModel.fileName + ".json");
|
||
|
fs.writeFile(filePath, storageModel.jsonString, 'utf-8', (err) => {
|
||
|
if (err) {
|
||
|
console.error('Error writing JSON to file:', err);
|
||
|
}
|
||
|
else {
|
||
|
console.log('JSON file saved successfully:', filePath);
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
exports.SaveProject = SaveProject;
|
||
|
//# sourceMappingURL=SaveProject.js.map
|