Skip to content

Commit 6d08f0c

Browse files
committed
Formatter.
1 parent 9cf9839 commit 6d08f0c

File tree

2 files changed

+49
-20
lines changed

2 files changed

+49
-20
lines changed

src/emulator/controller.spec.ts

+35-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { FakeEmulator } from "./testing/fakeEmulator";
66
import { EmulatorOptions } from "./controller";
77
import { ValidatedConfig } from "../functions/projectConfig";
88
import { Config } from "../config";
9-
import { Options } from "../options";
109

1110
describe("EmulatorController", () => {
1211
afterEach(async () => {
@@ -41,42 +40,70 @@ describe("EmulatorController", () => {
4140

4241
it("should include all codebases without only flag", () => {
4342
const options = { ...baseOptions };
44-
const backends = controller.prepareFunctionsBackends(options, functionsConfig, "/project/dir");
43+
const backends = controller.prepareFunctionsBackends(
44+
options,
45+
functionsConfig,
46+
"/project/dir",
47+
);
4548
expect(backends.length).to.equal(3);
46-
expect(backends.map((b) => b.codebase)).to.have.members(["codebasea", "codebaseb", undefined]);
49+
expect(backends.map((b) => b.codebase)).to.have.members([
50+
"codebasea",
51+
"codebaseb",
52+
undefined,
53+
]);
4754
});
4855

4956
it("should include only specified codebases", () => {
5057
const options = { ...baseOptions, only: "functions:codebasea" };
51-
const backends = controller.prepareFunctionsBackends(options, functionsConfig, "/project/dir");
58+
const backends = controller.prepareFunctionsBackends(
59+
options,
60+
functionsConfig,
61+
"/project/dir",
62+
);
5263
expect(backends.length).to.equal(1);
5364
expect(backends[0].codebase).to.equal("codebasea");
5465
});
5566

5667
it("should include all specified codebases", () => {
5768
const options = { ...baseOptions, only: "functions:codebasea,functions:codebaseb" };
58-
const backends = controller.prepareFunctionsBackends(options, functionsConfig, "/project/dir");
69+
const backends = controller.prepareFunctionsBackends(
70+
options,
71+
functionsConfig,
72+
"/project/dir",
73+
);
5974
expect(backends.length).to.equal(2);
6075
expect(backends.map((b) => b.codebase)).to.have.members(["codebasea", "codebaseb"]);
6176
});
6277

6378
it("should include default codebase", () => {
6479
const options = { ...baseOptions, only: "functions:default" };
65-
const backends = controller.prepareFunctionsBackends(options, functionsConfig, "/project/dir");
80+
const backends = controller.prepareFunctionsBackends(
81+
options,
82+
functionsConfig,
83+
"/project/dir",
84+
);
6685
expect(backends.length).to.equal(1);
6786
expect(backends[0].codebase).to.equal(undefined);
6887
});
6988

7089
it("should ignore non-functions filters", () => {
7190
const options = { ...baseOptions, only: "hosting,functions:codebasea" };
72-
const backends = controller.prepareFunctionsBackends(options, functionsConfig, "/project/dir");
91+
const backends = controller.prepareFunctionsBackends(
92+
options,
93+
functionsConfig,
94+
"/project/dir",
95+
);
7396
expect(backends.length).to.equal(1);
7497
expect(backends[0].codebase).to.equal("codebasea");
7598
});
7699

77100
it("should include all codebases given --only functions", () => {
78101
const options = { ...baseOptions, only: "functions" };
79-
const backends = controller.prepareFunctionsBackends(options, functionsConfig, "/project/dir");
102+
const backends = controller.prepareFunctionsBackends(
103+
options,
104+
functionsConfig,
105+
"/project/dir",
106+
);
80107
expect(backends.length).to.equal(3);
81108
});
82109
});

src/emulator/controller.ts

+14-12
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import { TasksEmulator } from "./tasksEmulator";
6161
import { AppHostingEmulator } from "./apphosting";
6262
import { sendVSCodeMessage, VSCODE_MESSAGE } from "../dataconnect/webhook";
6363
import { dataConnectLocalConnString } from "../api";
64-
import { EndpointFilter, getEndpointFilters } from "../deploy/functions/functionsDeployHelper";
64+
import { getEndpointFilters } from "../deploy/functions/functionsDeployHelper";
6565
import { ValidatedConfig } from "../functions/projectConfig";
6666

6767
const START_LOGGING_EMULATOR = utils.envOverride(
@@ -81,7 +81,7 @@ export async function exportOnExit(options: Options): Promise<void> {
8181
try {
8282
utils.logBullet(
8383
`Automatically exporting data using ${FLAG_EXPORT_ON_EXIT_NAME} "${exportOnExitDir}" ` +
84-
"please wait for the export to finish...",
84+
"please wait for the export to finish...",
8585
);
8686
await exportEmulatorData(exportOnExitDir, options, /* initiatedBy= */ "exit");
8787
} catch (e: unknown) {
@@ -128,8 +128,7 @@ export function prepareFunctionsBackends(
128128
const emulatableBackends: EmulatableBackend[] = [];
129129

130130
const filters = getEndpointFilters(options, true /* strict */);
131-
const codebaseFilters = filters
132-
?.map((f) => f.codebase)
131+
const codebaseFilters = filters?.map((f) => f.codebase);
133132

134133
const filterFn = (codebase: string): boolean => {
135134
if (!codebaseFilters) {
@@ -141,7 +140,11 @@ export function prepareFunctionsBackends(
141140
for (const cfg of functionsCfg) {
142141
const codebase = cfg.codebase ?? "default";
143142
if (!filterFn(codebase)) {
144-
functionsLogger.logLabeled("INFO", "functions", `Skipping codebase ${codebase} due to --only filter`);
143+
functionsLogger.logLabeled(
144+
"INFO",
145+
"functions",
146+
`Skipping codebase ${codebase} due to --only filter`,
147+
);
145148
continue;
146149
}
147150
const functionsDir = path.join(projectDir, cfg.source);
@@ -172,7 +175,6 @@ export function prepareFunctionsBackends(
172175
return emulatableBackends;
173176
}
174177

175-
176178
/**
177179
* Filters a list of emulators to only those specified in the config
178180
* @param options
@@ -425,9 +427,9 @@ export async function startAll(
425427
"ERROR",
426428
Emulators.EXTENSIONS,
427429
`Unable to look up project number for ${options.project}.\n` +
428-
" If this is a real project, ensure that you are logged in and have access to it.\n" +
429-
" If this is a fake project, please use a project ID starting with 'demo-' to skip production calls.\n" +
430-
" Continuing with a fake project number - secrets and other features that require production access may behave unexpectedly.",
430+
" If this is a real project, ensure that you are logged in and have access to it.\n" +
431+
" If this is a fake project, please use a project ID starting with 'demo-' to skip production calls.\n" +
432+
" Continuing with a fake project number - secrets and other features that require production access may behave unexpectedly.",
431433
);
432434
}
433435
}
@@ -946,7 +948,7 @@ export async function startAll(
946948
"WARN",
947949
"dataconnect",
948950
"'firebase.json#emulators.dataconnect.dataDir' is set and `--import` flag was passed. " +
949-
"This will overwrite any data saved from previous runs.",
951+
"This will overwrite any data saved from previous runs.",
950952
);
951953
if (
952954
!options.nonInteractive &&
@@ -1054,8 +1056,8 @@ export async function startAll(
10541056
"WARN",
10551057
"emulators",
10561058
"The Emulator UI is not starting, either because none of the running " +
1057-
"emulators have a UI component or the Emulator UI cannot " +
1058-
"determine the Project ID. Pass the --project flag to specify a project.",
1059+
"emulators have a UI component or the Emulator UI cannot " +
1060+
"determine the Project ID. Pass the --project flag to specify a project.",
10591061
);
10601062
}
10611063

0 commit comments

Comments
 (0)