Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Fixed an issue where `emulators:export` did not check if the target folder is empty. (#6313)
- Fix "Could not find the next executable" on Next.js deployments (#6372)
12 changes: 7 additions & 5 deletions src/emulator/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { LoggingEmulator } from "./loggingEmulator";
import * as dbRulesConfig from "../database/rulesConfig";
import { EmulatorLogger } from "./emulatorLogger";
import { EmulatorHubClient } from "./hubClient";
import { promptOnce } from "../prompt";
import { confirm } from "../prompt";
import {
FLAG_EXPORT_ON_EXIT_NAME,
JAVA_DEPRECATION_WARNING,
Expand Down Expand Up @@ -961,17 +961,19 @@ export async function exportEmulatorData(exportPath: string, options: any, initi

// Check if there is already an export there and prompt the user about deleting it
const existingMetadata = HubExport.readMetadata(exportAbsPath);
if (existingMetadata && !(options.force || options.exportOnExit)) {
const isExportDirEmpty = fs.readdirSync(exportAbsPath).length === 0;
if ((existingMetadata || !isExportDirEmpty) && !(options.force || options.exportOnExit)) {
if (options.noninteractive) {
throw new FirebaseError(
"Export already exists in the target directory, re-run with --force to overwrite.",
{ exit: 1 }
);
}

const prompt = await promptOnce({
type: "confirm",
message: `The directory ${exportAbsPath} already contains export data. Exporting again to the same directory will overwrite all data. Do you want to continue?`,
const prompt = await confirm({
message: `The directory ${exportAbsPath} is not empty. Existing files in this directory will be overwritten. Do you want to continue?`,
nonInteractive: options.nonInteractive,
force: options.force,
default: false,
});

Expand Down