Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

[config] Fix Android scandir error when ejecting on windows #2774

Merged
merged 2 commits into from Oct 9, 2020

Conversation

byCedric
Copy link
Member

@byCedric byCedric commented Oct 9, 2020

Fixes #2711

The issue originates (once again) from glob. This always returns a posix formatted path, even on Windows. This messes up the path.sep because that's different on Windows. I think it's a good thing to normalize paths when using glob, it changes the format of the path to the expected one on Windows.

It's also good to use path.relative more when stripping root paths. It takes all differences into account related to windows/posix paths and just returns you the path you need.

@byCedric
Copy link
Member Author

byCedric commented Oct 9, 2020

This doesn't fix the issue related to iOS splash screen configuration, I'm looking into that now.

Edit: this is related to some issues in the xcode dependency. Doesn't play nice with Windows-styled paths. See this issue

}

function getCurrentPackageName(projectRoot: string) {
const packageRoot = getPackageRoot(projectRoot);
const mainApplicationPath = getMainApplicationPath({ projectRoot, packageRoot });
const packagePath = path.dirname(mainApplicationPath);
const packagePathParts = packagePath.replace(packageRoot, '').split(path.sep).filter(Boolean);
const packagePathParts = path.relative(packageRoot, packagePath).split(path.sep).filter(Boolean);
Copy link
Member

Choose a reason for hiding this comment

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

clever

return mainApplications[0];
// Also, glob always returns a posix formatted path (even on windows),
// lets normalize that so we can use it with `.split(path.sep)`
return path.normalize(mainApplications[0]);
Copy link
Member

Choose a reason for hiding this comment

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

🔥

Copy link
Member

Choose a reason for hiding this comment

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

@byCedric - maybe we should make a wrapper around glob that always returns a normalized path to stop this from biting us in the future

@brentvatne brentvatne merged commit 6973eb6 into master Oct 9, 2020
@brentvatne brentvatne deleted the @bycedric/windows/fix-android-eject branch October 9, 2020 22:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENOENT: no such file or directory, scandir when ejecting
2 participants