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: run-android not finding scripts to overwrite #141

Merged
merged 4 commits into from
Feb 1, 2019
Merged
Changes from 1 commit
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
25 changes: 22 additions & 3 deletions packages/cli/src/runAndroid/runAndroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,28 @@ function startServerInNewWindow(port, terminal = process.env.REACT_TERMINAL) {
/**
* Set up the `.packager.(env|bat)` file to ensure the packager starts on the right port.
*/
const launchPackagerScript = require.resolve(
`react-native/scripts/${scriptFile}`
);
let launchPackagerScript;
try {
launchPackagerScript = require.resolve(
`react-native/scripts/${scriptFile}`
);
} catch (e) {
/**
* If the `react-native` package is missing, check if we are running from source.
*
* From `node_modules/@react-native-community/cli/build/run-android to `scripts/`
*/
const possibleScriptLocation = path.resolve(
__dirname,
`../../../../../scripts/${scriptFile}`
Copy link
Member

Choose a reason for hiding this comment

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

or you could add a new flag pathToReactNative which you could pass to RNTester scripts?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I think this is a good idea and would solve few other issues we had already in start command. Let me rewrite it by adding global --pathToReactNative flag (similar to root) so that users can pass it and we can decide where to use it.

This is amazing for debugging too!

);
if (!fs.existsSync(possibleScriptLocation)) {
throw new Error(
`Couldn't locate React Native files. To resolve this issue, try installing Node dependencies once again.`
);
}
launchPackagerScript = possibleScriptLocation;
}

/**
* Set up the `launchpackager.(command|bat)` file.
Expand Down