Skip to content

Commit 8fac095

Browse files
committed
handle empty files in tsclient
1 parent e8eef85 commit 8fac095

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

NpgsqlRestClient/appsettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,11 +1107,11 @@
11071107
//
11081108
"ExportEventSources": true,
11091109
//
1110-
// List if custom imports to add to the generated code. It adds line to a file. Use full expression like `import { MyType } from './my-type';`
1110+
// List of custom imports to add to the generated code. It adds line to a file. Use full expression like `import { MyType } from './my-type';`
11111111
//
11121112
"CustomImports": [],
11131113
//
1114-
// List if custom headers to add to the each request in generated code. Header key is automatically quoted if it doesn't contain quotes.
1114+
// Dictionary of custom headers to add to the each request in generated code. Header key is automatically quoted if it doesn't contain quotes.
11151115
//
11161116
"CustomHeaders": {}
11171117
},

plugins/NpgsqlRest.TsClient/TsClient.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,24 @@ options.ImportBaseUrlFrom is not null ?
190190
{
191191
if (File.Exists(fileName))
192192
{
193-
File.WriteAllText(fileName, content.ToString());
193+
try
194+
{
195+
File.Delete(fileName);
196+
_logger?.LogInformation("Deleted file: {fileName}", fileName);
197+
}
198+
catch (Exception ex)
199+
{
200+
_logger?.LogError(ex, "Failed to delete file: {fileName}", fileName);
201+
202+
try
203+
{
204+
File.WriteAllText(fileName, "// No endpoints found.");
205+
}
206+
catch (Exception ex2)
207+
{
208+
_logger?.LogError(ex2, "Failed to empty file: {fileName}", fileName);
209+
}
210+
}
194211
}
195212
}
196213
return;

0 commit comments

Comments
 (0)