From fa85567d5a2e0104f01f3e6b271a8027a5e08df5 Mon Sep 17 00:00:00 2001 From: nguyenkimbang Date: Tue, 17 Mar 2020 15:55:35 +0700 Subject: [PATCH 1/3] ignore error table --- src/ModelGeneration.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/ModelGeneration.ts b/src/ModelGeneration.ts index af573e9..b94d06b 100644 --- a/src/ModelGeneration.ts +++ b/src/ModelGeneration.ts @@ -80,13 +80,18 @@ function generateModels( ) : rendered ); - const formatted = Prettier.format(withImportStatements, { - parser: "typescript" - }); - fs.writeFileSync(resultFilePath, formatted, { - encoding: "UTF-8", - flag: "w" - }); + try { + const formatted = Prettier.format(withImportStatements, { + parser: 'typescript', + }); + fs.writeFileSync(resultFilePath, formatted, { + encoding: 'UTF-8', + flag: 'w', + }); + } catch (error) { + console.log('Trouble when generate for table: ', element.sqlName); + console.log(error); + } }); } From 4a7b1338f0c12fbaace66f14b397b238793daa60 Mon Sep 17 00:00:00 2001 From: Kononnable Date: Thu, 19 Mar 2020 17:37:00 +0100 Subject: [PATCH 2/3] Allow models which don't generate properly to be saved --- src/ModelGeneration.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/ModelGeneration.ts b/src/ModelGeneration.ts index b94d06b..97420f7 100644 --- a/src/ModelGeneration.ts +++ b/src/ModelGeneration.ts @@ -80,18 +80,22 @@ function generateModels( ) : rendered ); + let formatted = ""; try { - const formatted = Prettier.format(withImportStatements, { - parser: 'typescript', - }); - fs.writeFileSync(resultFilePath, formatted, { - encoding: 'UTF-8', - flag: 'w', + formatted = Prettier.format(withImportStatements, { + parser: "typescript" }); } catch (error) { - console.log('Trouble when generate for table: ', element.sqlName); + console.log( + "There were some problems with model generation for table: ", + element.sqlName + ); console.log(error); } + fs.writeFileSync(resultFilePath, formatted, { + encoding: "UTF-8", + flag: "w" + }); }); } From 4fad41cd103f00d072294f53e720585fbb3aacb6 Mon Sep 17 00:00:00 2001 From: Kononnable Date: Thu, 19 Mar 2020 18:28:12 +0100 Subject: [PATCH 3/3] proper fix of models which don't generate properly --- src/ModelGeneration.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ModelGeneration.ts b/src/ModelGeneration.ts index 97420f7..c72c91b 100644 --- a/src/ModelGeneration.ts +++ b/src/ModelGeneration.ts @@ -86,11 +86,12 @@ function generateModels( parser: "typescript" }); } catch (error) { - console.log( + console.error( "There were some problems with model generation for table: ", element.sqlName ); - console.log(error); + console.error(error); + formatted = withImportStatements; } fs.writeFileSync(resultFilePath, formatted, { encoding: "UTF-8",