Skip to content

Commit f8e0d31

Browse files
joehanbkendall
andauthored
Adding support for ${param:FOO} syntax (#2810)
* Adding support for ${param:FOO} syntax * add changelog Co-authored-by: Bryan Kendall <[email protected]>
1 parent 57666e5 commit f8e0d31

File tree

7 files changed

+15
-93
lines changed

7 files changed

+15
-93
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
- Fixes an issue where the `${param:FOO}` syntax for Firebase Extensions did not work with the emulator.
12
- Fixes issue in `database:settings:get` where the value wasn't being properly displayed.

src/extensions/emulator/optionsHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as fs from "fs-extra";
22
import * as _ from "lodash";
33
import * as path from "path";
4-
import * as paramHelper from "./paramHelper";
4+
import * as paramHelper from "../paramHelper";
55
import * as specHelper from "./specHelper";
66
import * as triggerHelper from "./triggerHelper";
77
import { Resource } from "../extensionsApi";

src/extensions/emulator/paramHelper.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/extensions/emulator/specHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as fs from "fs-extra";
66
import { fileExistsSync } from "../../fsutils";
77
import { ExtensionSpec, Resource } from "../extensionsApi";
88
import { FirebaseError } from "../../error";
9-
import { substituteParams } from "./paramHelper";
9+
import { substituteParams } from "../extensionsHelper";
1010
import { EmulatorLogger } from "../../emulator/emulatorLogger";
1111
import { Emulators } from "../../emulator/types";
1212

src/extensions/extensionsHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export async function getFirebaseProjectParams(projectId: string): Promise<any>
7878

7979
/**
8080
* This function substitutes params used in the extension spec with values.
81-
* (e.g If the original object contains `path/${FOO}` and the param FOO has the value of "bar",
81+
* (e.g If the original object contains `path/${FOO}` or `path/${param:FOO}` and the param FOO has the value of "bar",
8282
* then it will become `path/bar`)
8383
* @param original Object containing strings that have placeholders that look like`${}`
8484
* @param params params to substitute the placeholders for

src/extensions/paramHelper.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,14 @@ export async function promptForNewParams(
126126
}
127127
return currentParams;
128128
}
129+
130+
export function readParamsFile(envFilePath: string): any {
131+
try {
132+
const buf = fs.readFileSync(path.resolve(envFilePath), "utf8");
133+
return dotenv.parse(buf.toString().trim(), { debug: true });
134+
} catch (err) {
135+
throw new FirebaseError(`Error reading --test-params file: ${err.message}\n`, {
136+
original: err,
137+
});
138+
}
139+
}

src/test/extensions/emulator/paramHelper.spec.ts

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)