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

Conversation

csordasmarton
Copy link
Contributor

We are using spawn method to execute a CodeChecker command.
If the executable path starts with a ~ (e.g.: ~/CodeChecker/bin/CodeChecker),
the spawn method doesn't work properly and will give an exception.

For more information see: nodejs/node#684

To solve this problem we will expand the ~ in the file path before
executing the command.

@csordasmarton csordasmarton added this to the 1.3.0 milestone Feb 23, 2022
Copy link
Collaborator

@Discookie Discookie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small thing, otherwise LGTM!
I would've preferred a library for this, but for this simple one it's good enough.

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os.homedir is a function, not a string.
Technically it still works because .replace() accepts a (...) => string as second argument, but it'll fail on systems with no homedir.

We are using `spawn` method to execute a CodeChecker command.
If the executable path starts with a `~` (e.g.: `~/CodeChecker/bin/CodeChecker`),
the `spawn` method doesn't work properly and will give an exception.

For more information see: nodejs/node#684

To solve this problem we will expand the `~` in the file path before
executing the command.
Copy link
Collaborator

@Discookie Discookie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Discookie Discookie merged commit fc426e2 into Ericsson:main Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants