Skip to content

Commit

Permalink
Merge 692a948 into 14035dd
Browse files Browse the repository at this point in the history
  • Loading branch information
samtstern committed May 16, 2019
2 parents 14035dd + 692a948 commit 921d2a7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Expand Up @@ -6,3 +6,4 @@ fixed - Functions emulator fails to provide correct req.path
fixed - Functions emulator fails on various malformed body requests
fixed - Fixed race condition where downloading emulators would sometimes resolve too early and fail.
fixed - Fixed a number of issues that broke functions:shell.
fixed - Fixed an issue where Firestore emulator would not start if rules file can't be found.
22 changes: 17 additions & 5 deletions src/emulator/controller.ts
@@ -1,5 +1,6 @@
import * as _ from "lodash";
import * as clc from "cli-color";
import * as fs from "fs";
import * as pf from "portfinder";

import * as utils from "../utils";
Expand All @@ -10,7 +11,7 @@ import { ALL_EMULATORS, EmulatorInstance, Emulators } from "../emulator/types";
import { Constants } from "../emulator/constants";
import { FunctionsEmulator } from "../emulator/functionsEmulator";
import { DatabaseEmulator } from "../emulator/databaseEmulator";
import { FirestoreEmulator } from "../emulator/firestoreEmulator";
import { FirestoreEmulator, FirestoreEmulatorArgs } from "../emulator/firestoreEmulator";
import { HostingEmulator } from "../emulator/hostingEmulator";
import * as FirebaseError from "../error";
import * as path from "path";
Expand Down Expand Up @@ -123,13 +124,24 @@ export async function startAll(options: any): Promise<void> {

if (targets.indexOf(Emulators.FIRESTORE) > -1) {
const firestoreAddr = Constants.getAddress(Emulators.FIRESTORE, options);
const rules = path.join(options.projectRoot, options.config.get("firestore.rules"));

const firestoreEmulator = new FirestoreEmulator({
const args: FirestoreEmulatorArgs = {
host: firestoreAddr.host,
port: firestoreAddr.port,
rules,
});
};

const rules: string = path.join(options.projectRoot, options.config.get("firestore.rules"));
if (fs.existsSync(rules)) {
args.rules = rules;
} else {
utils.logWarning(
`Firestore rules file ${clc.bold(
rules
)} specified in firebase.json does not exist, starting Firestore emulator without rules.`
);
}

const firestoreEmulator = new FirestoreEmulator(args);
await startEmulator(firestoreEmulator);

utils.logLabeledBullet(
Expand Down
2 changes: 1 addition & 1 deletion src/emulator/firestoreEmulator.ts
Expand Up @@ -3,7 +3,7 @@ import { EmulatorInfo, EmulatorInstance, Emulators } from "../emulator/types";
import { EmulatorRegistry } from "./registry";
import { Constants } from "./constants";

interface FirestoreEmulatorArgs {
export interface FirestoreEmulatorArgs {
port?: number;
host?: string;
rules?: string;
Expand Down

0 comments on commit 921d2a7

Please sign in to comment.