Skip to content

Commit

Permalink
fix(init): fix bad package name in handleReactNativeConfig (#363)
Browse files Browse the repository at this point in the history
* fix(init): fix bad package name in handleReactNativeConfig

* chore(init): add changeset

---------

Co-authored-by: Rafał Zakrzewski <[email protected]>
  • Loading branch information
jbroma and RafikiTiki authored May 23, 2023
1 parent 0c43fe6 commit 470f10a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-rockets-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@callstack/repack-init": patch
---

Fix bad package name when creating/updating react-native.config.js
8 changes: 4 additions & 4 deletions packages/init/src/tasks/handleReactNativeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import logger from '../utils/logger.js';

const defaultConfig = dedent`
module.exports = {
commands: require('repack/commands'),
}`;
commands: require('@callstack/repack/commands'),
};`;

/**
* Checks whether react-native.config.js exists and adds the commands to it
Expand All @@ -29,14 +29,14 @@ export default function handleReactNativeConfig(cwd: string): void {
if (!configContent.includes('commands:')) {
updatedConfigContent = configContent.replace(
'module.exports = {',
"module.exports = {\n commands: require('repack/commands'),"
"module.exports = {\n commands: require('@callstack/repack/commands'),"
);
} else {
const commandsIndex = configContent.indexOf('commands:');
const commandsEndIndex = configContent.indexOf(',', commandsIndex);
const commandsString = configContent.slice(commandsIndex, commandsEndIndex);

const newCommandsString = `commands: require('repack/commands')`;
const newCommandsString = `commands: require('@callstack/repack/commands')`;
if (commandsString === newCommandsString) {
logger.success('File react-native.config.js is already up to date');
return;
Expand Down

0 comments on commit 470f10a

Please sign in to comment.