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

Normalize appRootPath to prevent issues on Windows #3028

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 5 additions & 2 deletions packages/workspace/src/utils/app-root.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { fileExists } from './fileutils';
import * as path from 'path';

// TODO: vsavkin normalize the path
export const appRootPath = pathInner(__dirname);
function normalizeBackslashes(dir) {
Copy link

@georgiee georgiee May 18, 2020

Choose a reason for hiding this comment

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

While looking at this, I think we should stay path delimiter separator agnostic instead of forcing windows into using forward slashes. Otherwise we could run into other issues in unknown places where app-root is being used. Apart from this it's a good start for a discussion. I'm excited to see the CI/CD results if this fixes it or if implications of this change are correctly revealed by the CI/CD.

Let's wait for some maintainer comments. Thank you for crafting this PR 👍

Reference:
https://nodejs.org/api/path.html#path_path_delimiter
https://nodejs.org/api/path.html#path_path_sep

Copy link
Author

Choose a reason for hiding this comment

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

I guess you meant https://nodejs.org/api/path.html#path_path_sep not delimiter. You may be right, let's wait for maintainers feedback.

Choose a reason for hiding this comment

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

Oh yes, I just searched for a path example and cited the wrong section. I wanted to mention the path separator of course. Thanks for pointing out 👍

return dir.replace(/\\/g,'/')
}

export const appRootPath = normalizeBackslashes(pathInner(__dirname));

function pathInner(dir: string): string {
if (path.dirname(dir) === dir) return process.cwd();
Expand Down