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

feat: allow overriding commands from react-native.config.js #2229

Merged
merged 4 commits into from
Jan 15, 2024

Conversation

szymonrybczak
Copy link
Collaborator

Summary:

Closes #2227, from now commands added inside react-native.config.js will override existing ones.

Test Plan:

  1. Clone the repository and do all the required steps from the Contributing guide
  2. Createreact-native.config.js file with following content:
module.exports = {
  commands: [
    {
      name: 'start',
      func: () => {
        console.log('hello!');
      },
    },
  ],
};
  1. Run this command:
node /path/to/react-native-cli/packages/cli/build/bin.js start
  1. Command should be replaced ✅

Checklist

  • Documentation is up to date to reflect these changes.
  • Follows commit message convention described in CONTRIBUTING.md

@szymonrybczak szymonrybczak changed the title feat: allow overriding commands feat: allow to override commands from react-native.config.js Dec 21, 2023
@szymonrybczak szymonrybczak changed the title feat: allow to override commands from react-native.config.js feat: allow overriding commands from react-native.config.js Dec 21, 2023
@tom-sherman
Copy link

Any idea how we can make this work for start? In my testing the one added by react-native takes precedence over the one in my config.

@szymonrybczak
Copy link
Collaborator Author

In my testing the one added by react-native takes precedence over the one in my config.

I don't quite understand what do you mean here 🤔

I created new project, added Re.Pack with npx @callstack/repack-init and command is correctly overwritten.

CleanShot.2023-12-22.at.16.38.03.mp4

@szymonrybczak
Copy link
Collaborator Author

@tom-sherman bump :) ⬆️

@tom-sherman
Copy link

Hmm, could it be the react native version I'm running? I tried applying this as a patch to my RN 0.72.5 app and it continued to use metro.

It's probably just my setup in any case, so pls don't block the PR on my experience!

@szymonrybczak
Copy link
Collaborator Author

Hmm, could it be the react native version I'm running?

I don't think so. Did you follow CONTRIBUTING.md?

@tom-sherman
Copy link

tom-sherman commented Jan 2, 2024

I applied the change manually with pnpm patch, so again could be something I did wrong there also 😅

@thymikee
Copy link
Member

thymikee commented Jan 3, 2024

Let's add a test for this behavior in index-test.ts. The writeFiles should include 2 dependency commands and one root config that overrides one of the commands explicitly.

@szymonrybczak
Copy link
Collaborator Author

Let's add a test for this behavior in index-test.ts. The writeFiles should include 2 dependency commands and one root config that overrides one of the commands explicitly.

Done ✅

Copy link
Member

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

Let's document this

@github-actions github-actions bot added the docs Documentation change label Jan 15, 2024
@thymikee thymikee merged commit db2bd3e into main Jan 15, 2024
10 checks passed
@thymikee thymikee deleted the feat/allow-to-override-commands branch January 15, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation change feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow plugins to override built in commands
3 participants