Skip to content

Commit 32375ca

Browse files
committed
Fix log paths starting with ~
1 parent a424a6b commit 32375ca

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/extension.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { CommandNames } from './commands/constants';
2323
import { ImportIdentifier } from './commands/importIdentifier';
2424
import { DocsBrowser } from './docsBrowser';
2525
import { downloadHaskellLanguageServer } from './hlsBinaries';
26-
import { directoryExists, executableExists, ExtensionLogger, resolvePathPlaceHolders } from './utils';
26+
import { directoryExists, executableExists, expandHomeDir, ExtensionLogger, resolvePathPlaceHolders } from './utils';
2727

2828
// Used for environment variables later on
2929
interface IEnvVars {
@@ -171,11 +171,11 @@ async function activateServerForFolder(context: ExtensionContext, uri: Uri, fold
171171

172172
const logLevel = workspace.getConfiguration('haskell', uri).trace.server;
173173
const clientLogLevel = workspace.getConfiguration('haskell', uri).trace.client;
174-
const logFile = workspace.getConfiguration('haskell', uri).logFile;
174+
const logFile: string = workspace.getConfiguration('haskell', uri).logFile;
175175

176176
const outputChannel: OutputChannel = window.createOutputChannel(langName);
177177

178-
const logFilePath = logFile ? path.resolve(currentWorkingDir, logFile) : undefined;
178+
const logFilePath = path.resolve(currentWorkingDir, expandHomeDir(logFile));
179179
const logger: Logger = new ExtensionLogger('client', clientLogLevel, outputChannel, logFilePath);
180180
if (logFilePath) {
181181
logger.info(`Writing client log to file ${logFilePath}`);

src/utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,13 @@ export function directoryExists(path: string): boolean {
288288
return fs.existsSync(path) && fs.lstatSync(path).isDirectory();
289289
}
290290

291+
export function expandHomeDir(path: string): string {
292+
if (path.startsWith('~')) {
293+
return path.replace('~', os.homedir);
294+
}
295+
return path;
296+
}
297+
291298
export function resolvePathPlaceHolders(path: string, folder?: WorkspaceFolder) {
292299
path = path.replace('${HOME}', os.homedir).replace('${home}', os.homedir).replace(/^~/, os.homedir);
293300
if (folder) {

0 commit comments

Comments
 (0)