diff --git a/api/src/controllers/migration.controller.ts b/api/src/controllers/migration.controller.ts index 1c03631f..c90c7b6b 100644 --- a/api/src/controllers/migration.controller.ts +++ b/api/src/controllers/migration.controller.ts @@ -25,6 +25,9 @@ const getAuditData = async (req: Request, res: Response): Promise => { */ const startTestMigration = async (req: Request, res: Response): Promise => { const resp = migrationService.startTestMigration(req); + Promise.resolve(resp).catch((err) => { + console.error('startTestMigration failed', err); + }); res.status(200).json(resp); }; @@ -38,6 +41,9 @@ const startTestMigration = async (req: Request, res: Response): Promise => */ const startMigration = async (req: Request, res: Response): Promise => { const resp = migrationService.startMigration(req); + Promise.resolve(resp).catch((err) => { + console.error('startMigration failed', err); + }); res.status(200).json(resp); }; diff --git a/api/src/services/contentful.service.ts b/api/src/services/contentful.service.ts index df1f8850..070d89f6 100644 --- a/api/src/services/contentful.service.ts +++ b/api/src/services/contentful.service.ts @@ -335,11 +335,7 @@ async function readFile(filePath: string, fileName: string) { * @throws {Error} - If there is an error writing the file. */ async function writeOneFile(indexPath: string, fileMeta: any) { - fs.writeFile(indexPath, JSON.stringify(fileMeta), (err) => { - if (err) { - console.error("Error writing file: 3", err); - } - }); + await fs.promises.writeFile(indexPath, JSON.stringify(fileMeta)); } /** @@ -798,6 +794,7 @@ const createAssets = async (packagePath: any, destination_stack_id: string, proj ); await Promise.all(tasks); + await fs.promises.mkdir(assetsSave, { recursive: true }); const assetMasterFolderPath = path.join(assetsSave, ASSETS_FAILED_FILE); await writeOneFile(path.join(assetsSave, ASSETS_SCHEMA_FILE), assetData); @@ -833,6 +830,7 @@ const createAssets = async (packagePath: any, destination_stack_id: string, proj err ) await customLogger(projectId, destination_stack_id, 'error', message); + throw err; } };