Skip to content

Commit

Permalink
Fix relative dataDir issue (#8103)
Browse files Browse the repository at this point in the history
  • Loading branch information
joehan authored Jan 6, 2025
1 parent 625ae73 commit a1d61ec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Updated `cross-env` and `cross-spawn` dependencies to avoid vulnerable versions. (#7979)
- Fixed an issue with the Data Connect emulator where `dataDir` and `--export` were relative to the current directory insead of `firebase.json`.
2 changes: 1 addition & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions src/emulator/dataconnectEmulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,12 @@ export class DataConnectEmulator implements EmulatorInstance {
`FIREBASE_DATACONNECT_POSTGRESQL_STRING is set to ${clc.bold(connStr)} - using that instead of starting a new database`,
);
} else if (pgHost && pgPort) {
const dataDirectory = this.args.config.get("emulators.dataconnect.dataDir");
let dataDirectory = this.args.config.get("emulators.dataconnect.dataDir");
if (dataDirectory) {
dataDirectory = this.args.config.path(dataDirectory);
}
const postgresDumpPath = this.args.importPath
? path.join(this.args.importPath, "postgres.tar.gz")
? path.join(this.args.config.path(this.args.importPath), "postgres.tar.gz")
: undefined;
this.postgresServer = new PostgresServer({
dataDirectory,
Expand Down Expand Up @@ -205,7 +208,9 @@ export class DataConnectEmulator implements EmulatorInstance {

async exportData(exportPath: string): Promise<void> {
if (this.postgresServer) {
await this.postgresServer.exportData(path.join(exportPath, "postgres.tar.gz"));
await this.postgresServer.exportData(
path.join(this.args.config.path(exportPath), "postgres.tar.gz"),
);
} else {
throw new FirebaseError(
"The Data Connect emulator is currently connected to a separate Postgres instance. Export is not supported.",
Expand Down

0 comments on commit a1d61ec

Please sign in to comment.