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

fix: resolve junctions on Windows #117

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
16 changes: 10 additions & 6 deletions packages/sdk/android/resolveNodePackage.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
// source: https://github.com/facebook/react-native/pull/39520
// TODO remove in the future when this lands in RN
// modified to better support resolving symlinks(junctions) on Windows

import java.nio.file.*

ext.resolveNodePackage = { String packageName, File startDir ->
def candidate = new File(startDir, "node_modules/$packageName")
def startPath = startDir.toPath()
def candidate = startPath.resolve("node_modules").resolve(packageName)

if (candidate.exists()) {
return candidate.canonicalFile
if (Files.exists(candidate)) {
return candidate.toRealPath().toFile()
}

def parentDir = startDir.parentFile
if (parentDir == null || startDir.canonicalPath == parentDir.canonicalPath) {
def parentDir = startPath.parent
if (parentDir == null || startPath.toRealPath() == parentDir.toRealPath()) {
throw new GradleException("Failed to find the package '$packageName'. Ensure you have installed node_modules.")
}

return resolveNodePackage(packageName, parentDir)
return resolveNodePackage(packageName, parentDir.toFile())
}