Skip to content

Commit 731b7d2

Browse files
fsonthymikee
authored andcommitted
fix: reporter config option (#371)
* fix: reporter config option (#370) The `loadConfig` function in `metro-config` reads the `reporter` option from the second argument (`defaultConfigOverrides`) instead of the first argument (`argv`), so we need to pass it in that object to make the `customLogReporterPath` CLI option work. * chore: linting errors
1 parent f295ae1 commit 731b7d2

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

packages/cli/src/commands/upgrade/__tests__/upgrade.test.js

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,12 @@ success Upgraded React Native to v0.58.4 🎉. Now you can review and commit the
170170
`);
171171
});
172172

173-
test('fetches regular patch, adds remote, applies patch, installs deps, removes remote,', async () => {
174-
(fetch: any).mockImplementation(() => Promise.resolve(samplePatch));
175-
await upgrade.func([newVersion], ctx, opts);
176-
expect(flushOutput()).toMatchInlineSnapshot(`
173+
test(
174+
'fetches regular patch, adds remote, applies patch, installs deps, removes remote,',
175+
async () => {
176+
(fetch: any).mockImplementation(() => Promise.resolve(samplePatch));
177+
await upgrade.func([newVersion], ctx, opts);
178+
expect(flushOutput()).toMatchInlineSnapshot(`
177179
"info Fetching diff between v0.57.8 and v0.58.4...
178180
[fs] write tmp-upgrade-rn.patch
179181
$ execa git rev-parse --show-prefix
@@ -192,18 +194,22 @@ info Running \\"git status\\" to check what changed...
192194
$ execa git status
193195
success Upgraded React Native to v0.58.4 🎉. Now you can review and commit the changes"
194196
`);
195-
expect(
196-
snapshotDiff(samplePatch, fs.writeFileSync.mock.calls[0][1], {
197-
contextLines: 1,
198-
}),
199-
).toMatchSnapshot('RnDiffApp is replaced with app name (TestApp)');
200-
}, 60000);
201-
test('fetches regular patch, adds remote, applies patch, installs deps, removes remote when updated from nested directory', async () => {
202-
(fetch: any).mockImplementation(() => Promise.resolve(samplePatch));
203-
(execa: any).mockImplementation(mockExecaNested);
204-
const config = {...ctx, root: '/project/root/NestedApp'};
205-
await upgrade.func([newVersion], config, opts);
206-
expect(flushOutput()).toMatchInlineSnapshot(`
197+
expect(
198+
snapshotDiff(samplePatch, fs.writeFileSync.mock.calls[0][1], {
199+
contextLines: 1,
200+
}),
201+
).toMatchSnapshot('RnDiffApp is replaced with app name (TestApp)');
202+
},
203+
60000,
204+
);
205+
test(
206+
'fetches regular patch, adds remote, applies patch, installs deps, removes remote when updated from nested directory',
207+
async () => {
208+
(fetch: any).mockImplementation(() => Promise.resolve(samplePatch));
209+
(execa: any).mockImplementation(mockExecaNested);
210+
const config = {...ctx, root: '/project/root/NestedApp'};
211+
await upgrade.func([newVersion], config, opts);
212+
expect(flushOutput()).toMatchInlineSnapshot(`
207213
"info Fetching diff between v0.57.8 and v0.58.4...
208214
[fs] write tmp-upgrade-rn.patch
209215
$ execa git rev-parse --show-prefix
@@ -222,7 +228,9 @@ info Running \\"git status\\" to check what changed...
222228
$ execa git status
223229
success Upgraded React Native to v0.58.4 🎉. Now you can review and commit the changes"
224230
`);
225-
}, 60000);
231+
},
232+
60000,
233+
);
226234
test('cleans up if patching fails,', async () => {
227235
(fetch: any).mockImplementation(() => Promise.resolve(samplePatch));
228236
(execa: any).mockImplementation((command, args) => {

packages/cli/src/tools/loadMetroConfig.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ export type ConfigOptionsT = {|
8888
*/
8989
export default function load(ctx: ContextT, options?: ConfigOptionsT) {
9090
const defaultConfig = getDefaultConfig(ctx);
91-
92-
return loadConfig({cwd: ctx.root, ...options}, defaultConfig);
91+
return loadConfig(
92+
{cwd: ctx.root, ...options},
93+
{...defaultConfig, reporter: options && options.reporter},
94+
);
9395
}

0 commit comments

Comments
 (0)