Skip to content

Commit 819b802

Browse files
Ensure log directory is created (#1219)
* Ensure log directory is created * remove duplicate check
1 parent 2c67277 commit 819b802

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/PowerShellEditorServices.Hosting/Commands/StartEditorServicesCommand.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,14 @@ private void StartLogging()
298298

299299
private string GetLogDirPath()
300300
{
301-
if (!string.IsNullOrEmpty(LogPath))
302-
{
303-
return Path.GetDirectoryName(LogPath);
304-
}
301+
string logDir = !string.IsNullOrEmpty(LogPath)
302+
? Path.GetDirectoryName(LogPath)
303+
: Path.GetDirectoryName(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
304+
305+
// Ensure logDir exists
306+
Directory.CreateDirectory(logDir);
305307

306-
return Path.GetDirectoryName(
307-
Path.GetDirectoryName(
308-
Assembly.GetExecutingAssembly().Location));
308+
return logDir;
309309
}
310310

311311
private void RemovePSReadLineForStartup()

0 commit comments

Comments
 (0)