refactor: small tweaks and fixes

This commit is contained in:
Carlos Valente
2024-03-06 22:42:20 +01:00
committed by GitHub
parent 8196ea584d
commit d22cc48565
61 changed files with 401 additions and 198 deletions
@@ -14,6 +14,7 @@ import { appStateService } from '../app-state-service/AppStateService.js';
import { ensureDirectory, getFilesFromFolder, removeFileExtension } from '../../utils/fileManagement.js';
import { dbModel } from '../../models/dataModel.js';
import { deleteFile } from '../../utils/parserUtils.js';
import { switchDb } from '../../setup/loadDb.js';
// init dependencies
init();
@@ -40,6 +41,9 @@ export async function applyProjectFile(filePath: string, options?: Options) {
const newFilePath = join(resolveProjectsDirectory, filename);
await rename(filePath, newFilePath);
// change LowDB to point to new file
await switchDb(filename);
// apply data model
await applyDataModel(data, options);
@@ -135,6 +139,9 @@ export async function createProjectFile(filename: string, projectData: ProjectDa
const newFile = join(resolveProjectsDirectory, filename);
await writeFile(newFile, JSON.stringify(data));
// change LowDB to point to new file
await switchDb(filename);
// apply its data
await applyDataModel(data);