mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
fix: ensure --build-output destination exists (#45182)
Summary: Replicates https://github.com/react-native-community/cli/commit/48d4c29bba4e8b16cbc8307bd1b4c5349f3651d8, which landed inside `cli-plugin-metro` inside RNC CLI, but because of migration of code to `community-cli-plugin` it looks like apparently the fix wasn't replicated. ## Changelog: [GENERAL] [FIXED] - Ensure `--build-output` destination exists Pull Request resolved: https://github.com/facebook/react-native/pull/45182 Test Plan: Specify a new directory that doesn't exists inside `--build-output`: `npx react-native bundle --build-output dist/new-dir/index.bundle` and this command shouldn't fail. Reviewed By: christophpurrer Differential Revision: D61850942 Pulled By: huntie fbshipit-source-id: 90e57f19c661ace8206162d6fa2e6a27acb31e20
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3a77e6e275
commit
396bdd87d8
@@ -18,6 +18,7 @@ import {logger} from '../../utils/logger';
|
||||
import parseKeyValueParamArray from '../../utils/parseKeyValueParamArray';
|
||||
import saveAssets from './saveAssets';
|
||||
import chalk from 'chalk';
|
||||
import {promises as fs} from 'fs';
|
||||
import Server from 'metro/src/Server';
|
||||
import metroBundle from 'metro/src/shared/output/bundle';
|
||||
import metroRamBundle from 'metro/src/shared/output/RamBundle';
|
||||
@@ -112,6 +113,12 @@ async function buildBundleWithConfig(
|
||||
try {
|
||||
const bundle = await bundleImpl.build(server, requestOpts);
|
||||
|
||||
// Ensure destination directory exists before saving the bundle
|
||||
await fs.mkdir(path.dirname(args.bundleOutput), {
|
||||
recursive: true,
|
||||
mode: 0o755,
|
||||
});
|
||||
|
||||
// $FlowIgnore[class-object-subtyping]
|
||||
// $FlowIgnore[incompatible-call]
|
||||
// $FlowIgnore[prop-missing]
|
||||
|
||||
Reference in New Issue
Block a user