Skip to content

Commit

Permalink
Ask before overwriting storage.rules (firebase#3510)
Browse files Browse the repository at this point in the history
  • Loading branch information
samtstern authored and devpeerapong committed Dec 14, 2021
1 parent e2e18c6 commit 8925ac1
Show file tree
Hide file tree
Showing 3 changed files with 5 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 @@
- Avoid emulator data loss when there an error during export (#3504)
- Ask before overwriting `storage.rules` during `firebase init` (#1833)
2 changes: 1 addition & 1 deletion src/init/features/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ export async function doSetup(setup: any, config: any): Promise<void> {
default: "storage.rules",
});
setup.config.storage.rules = storageRulesFile;
config.writeProjectFile(setup.config.storage.rules, RULES_TEMPLATE);
await config.askWriteProjectFile(setup.config.storage.rules, RULES_TEMPLATE);
}
6 changes: 3 additions & 3 deletions src/test/init/features/storage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import * as prompt from "../../../prompt";

describe("storage", () => {
const sandbox: sinon.SinonSandbox = sinon.createSandbox();
let writeProjectFileStub: sinon.SinonStub;
let askWriteProjectFileStub: sinon.SinonStub;
let promptStub: sinon.SinonStub;

beforeEach(() => {
writeProjectFileStub = sandbox.stub(Config.prototype, "writeProjectFile");
askWriteProjectFileStub = sandbox.stub(Config.prototype, "askWriteProjectFile");
promptStub = sandbox.stub(prompt, "promptOnce");
});

Expand All @@ -30,7 +30,7 @@ describe("storage", () => {
projectLocation: "us-central",
};
promptStub.returns("storage.rules");
writeProjectFileStub.resolves();
askWriteProjectFileStub.resolves();

await doSetup(setup, new Config("/path/to/src", {}));

Expand Down

0 comments on commit 8925ac1

Please sign in to comment.