ConceptCreator/app/SaveProject.js
Sebastian Böckelmann d56166b245
All checks were successful
E2E Testing / test (push) Successful in 1m31s
Restructure Saving Logic to extra class and save on Strg+S + display changed savestatus in editor
2024-02-17 07:30:29 +01:00

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