Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 949
fix: custom root or calling Gradle outside of project directory#1057
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
5e2958a41ef45f144ead1149d78f8e1d863f7d498972b18951bf5c7396a78df1138ca2c24f0ae09aec54File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import path from 'path'; | ||
| import { | ||
| spawnScript, | ||
| runCLI, | ||
| getTempDirectory, | ||
| cleanup, | ||
| writeFiles, | ||
| } from '../jest/helpers'; | ||
| const cwd = getTempDirectory('test_different_roots'); | ||
| beforeAll(() => { | ||
| // Register all packages to be linked | ||
| for (const pkg of ['platform-ios', 'platform-android']) { | ||
| spawnScript('yarn', ['link'], { | ||
| cwd: path.join(__dirname, `../packages/${pkg}`), | ||
| }); | ||
| } | ||
| // Clean up folder and re-create a new project | ||
| cleanup(cwd); | ||
| writeFiles(cwd, {}); | ||
| // Initialise React Native project | ||
| runCLI(cwd, ['init', 'TestProject']); | ||
| // Link CLI to the project | ||
| const pkgs = [ | ||
| '@react-native-community/cli-platform-ios', | ||
| '@react-native-community/cli-platform-android', | ||
| ]; | ||
| spawnScript('yarn', ['link', ...pkgs], { | ||
| cwd: path.join(cwd, 'TestProject'), | ||
| }); | ||
| }); | ||
| afterAll(() => { | ||
| cleanup(cwd); | ||
| }); | ||
| test('works when Gradle is run outside of the project hierarchy', () => { | ||
| /** | ||
| * Location of Android project | ||
| */ | ||
| const androidProjectRoot = path.join(cwd, 'TestProject/android'); | ||
| /* | ||
| * Grab absolute path to Gradle wrapper. The fact that we are using | ||
| * a wrapper from the project is just a convinience to avoid installing | ||
| * Gradle globally | ||
| */ | ||
| const gradleWrapper = path.join(androidProjectRoot, 'gradlew'); | ||
| // Execute `gradle` with `-p` flag and `cwd` outside of project hierarchy | ||
| const {stdout} = spawnScript(gradleWrapper, ['-p', androidProjectRoot], { | ||
| cwd: '/', | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to set cwd here? I'd expect a default value would be sufficient – this way we could make the MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Truth is - we never want to rely on In this case, I just want to make sure and be 100% explicit that MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The reason why I believe it's better to require Conceptually, I think of | ||
| }); | ||
| expect(stdout).toContain('BUILD SUCCESSFUL'); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.