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

use path instead of posix-specific path #40

Merged
merged 3 commits into from
Jul 29, 2022
Merged

use path instead of posix-specific path #40

merged 3 commits into from
Jul 29, 2022

Conversation

Randelung
Copy link

@Randelung Randelung commented Jul 28, 2022

addresses #38, but likely doesn't fully eliminate the issue.

I've noticed that there's a lot of explicit posix type path usage and manual path parsing etc. It seems to me that the scope of the extension is merely a bridge between karma/angular-cli and the UI, which leads me to believe that manual path wrangling (posix paths on windows and vice versa) shouldn't really be necessary.
I don't want to break stuff I don't fully understand, so I only took out any posix path manipulation that touches angularConfigRootPath in angular-utils since I can see that it's a windows path from the start, but I'm certain that the same could be done throughout the project. I generally advise against manual path manipulation and explicit platform distinction.

This change correctly identifed my angular project on my D: drive and started the angular cli (without any manual settings). Test detection and execution work as expected. I did npm validate and got 225/238 tests passed, the same as on master.

I've taken the liberty to increment the path level.

addresses #38, but likely doesn't fully eliminate the issue.
@Randelung
Copy link
Author

Randelung commented Jul 28, 2022

... Actually, this probably doesn't have anything to do with #38, sorry. 😅 It addresses a different issue and I inadvertently hijacked the thread.

@Randelung
Copy link
Author

Oh yeah, I forgot to mention. Somebody should try it out on a Linux machine before merging.

@lucono
Copy link
Owner

lucono commented Jul 29, 2022

@Randelung, thanks for looking into this, and for the PR.

Karma Test Explorer project only uses posix-style paths, as they are understood by all 3 platforms (Linux, MacOS, Windows). Additionally, it doesn't use the shell option of child_process.spawn for a number of reasons (see previous issues #2, #9, and #12 for example).

Not using the shell option allows it to fully delegate path escaping concerns to each OS platform. Karma Test Explorer takes the same approach used by Angular here for a lot of the same reasons.

Edit: The issue in the code is that the resolve should have been a join, and has a missing normalizePath. If you could address those and add unit tests (which the build will validate on all 3 platforms), I can merge it into the beta branch for release.

@lucono lucono changed the base branch from master to beta July 29, 2022 12:46
Randolph Busch added 2 commits July 29, 2022 15:51
replace resolve with join where appropriate
introduce try/catch for JSON.parse
test suite for angular-utils
@lucono
Copy link
Owner

lucono commented Jul 29, 2022

@Randelung Thanks for the updates. I'm going to add some additional fixes and release to the store.

@lucono lucono merged commit 4f58062 into lucono:beta Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants