Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand user in the CodeChecker binary path #98

Merged
merged 1 commit into from
Feb 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/backend/executor/process.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as child_process from 'child_process';
import * as os from 'os';
import { quote } from 'shell-quote';
import { Disposable, Event, EventEmitter, ExtensionContext, workspace } from 'vscode';

Expand All @@ -19,6 +20,13 @@ export enum ProcessType {
other = 'Other process',
}

const homeDir = os.homedir();

// Expand an initial '~' component in the given path if there is any, otherwise returns the file path without changes.
function expandUser(filePath: string) {
return homeDir ? filePath.replace(/^~(?=$|\/|\\)/, homeDir) : filePath;
}

export interface ProcessParameters {
/** Default: true, false when type is parse */
forwardStdoutToLogs?: boolean,
Expand Down Expand Up @@ -84,7 +92,7 @@ export class ScheduledProcess implements Disposable {
}

constructor(executable: string, commandArgs?: string[], parameters?: ProcessParameters) {
this.executable = executable;
this.executable = expandUser(executable);
this.commandArgs = commandArgs ?? [];
this.processParameters = parameters ?? {};

Expand Down