Skip to content

Commit a1d61ec

Browse files
authored
Fix relative dataDir issue (#8103)
1 parent 625ae73 commit a1d61ec

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
- Updated `cross-env` and `cross-spawn` dependencies to avoid vulnerable versions. (#7979)
2+
- Fixed an issue with the Data Connect emulator where `dataDir` and `--export` were relative to the current directory insead of `firebase.json`.

npm-shrinkwrap.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/emulator/dataconnectEmulator.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,12 @@ export class DataConnectEmulator implements EmulatorInstance {
114114
`FIREBASE_DATACONNECT_POSTGRESQL_STRING is set to ${clc.bold(connStr)} - using that instead of starting a new database`,
115115
);
116116
} else if (pgHost && pgPort) {
117-
const dataDirectory = this.args.config.get("emulators.dataconnect.dataDir");
117+
let dataDirectory = this.args.config.get("emulators.dataconnect.dataDir");
118+
if (dataDirectory) {
119+
dataDirectory = this.args.config.path(dataDirectory);
120+
}
118121
const postgresDumpPath = this.args.importPath
119-
? path.join(this.args.importPath, "postgres.tar.gz")
122+
? path.join(this.args.config.path(this.args.importPath), "postgres.tar.gz")
120123
: undefined;
121124
this.postgresServer = new PostgresServer({
122125
dataDirectory,
@@ -205,7 +208,9 @@ export class DataConnectEmulator implements EmulatorInstance {
205208

206209
async exportData(exportPath: string): Promise<void> {
207210
if (this.postgresServer) {
208-
await this.postgresServer.exportData(path.join(exportPath, "postgres.tar.gz"));
211+
await this.postgresServer.exportData(
212+
path.join(this.args.config.path(exportPath), "postgres.tar.gz"),
213+
);
209214
} else {
210215
throw new FirebaseError(
211216
"The Data Connect emulator is currently connected to a separate Postgres instance. Export is not supported.",

0 commit comments

Comments
 (0)