Skip to content

Commit 88a9db0

Browse files
committed
Move REACT_NATIVE_OVERRIDE_HERMES_DIR out of tasks to fail earlier
1 parent beff0f9 commit 88a9db0

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

.changeset/red-candles-sell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-native-node-api": patch
3+
---
4+
5+
Move REACT_NATIVE_OVERRIDE_HERMES_DIR out of tasks to fail earlier

packages/host/android/build.gradle

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@ import java.nio.file.Paths
22
import groovy.json.JsonSlurper
33
import org.gradle.internal.os.OperatingSystem
44

5+
if (!System.getenv("REACT_NATIVE_OVERRIDE_HERMES_DIR")) {
6+
throw new GradleException([
7+
"React Native Node-API needs a custom version of Hermes with Node-API enabled.",
8+
"Run the following in your terminal, to clone Hermes and instruct React Native to use it:",
9+
"",
10+
"export REACT_NATIVE_OVERRIDE_HERMES_DIR=\$(npx react-native-node-api vendor-hermes --silent --force)",
11+
"",
12+
"And follow this guide to build React Native from source:",
13+
"https://reactnative.dev/contributing/how-to-build-from-source#update-your-project-to-build-from-source"
14+
].join('\n'))
15+
}
16+
517
buildscript {
618
ext.getExtOrDefault = {name ->
719
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['NodeApiModules_' + name]
@@ -135,22 +147,6 @@ dependencies {
135147
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
136148
}
137149

138-
task checkHermesOverride {
139-
doFirst {
140-
if (!System.getenv("REACT_NATIVE_OVERRIDE_HERMES_DIR")) {
141-
throw new GradleException([
142-
"React Native Node-API needs a custom version of Hermes with Node-API enabled.",
143-
"Run the following in your terminal, to clone Hermes and instruct React Native to use it:",
144-
"",
145-
"export REACT_NATIVE_OVERRIDE_HERMES_DIR=\$(npx react-native-node-api vendor-hermes --silent --force)",
146-
"",
147-
"And follow this guide to build React Native from source:",
148-
"https://reactnative.dev/contributing/how-to-build-from-source#update-your-project-to-build-from-source"
149-
].join('\n'))
150-
}
151-
}
152-
}
153-
154150
def commandLinePrefix = OperatingSystem.current().isWindows() ? ["cmd", "/c", "node"] : []
155151
def cliPath = file("../bin/react-native-node-api.mjs")
156152

@@ -169,5 +165,5 @@ task linkNodeApiModules {
169165
}
170166
}
171167

172-
preBuild.dependsOn checkHermesOverride, linkNodeApiModules
168+
preBuild.dependsOn linkNodeApiModules
173169

0 commit comments

Comments
 (0)