-
Notifications
You must be signed in to change notification settings - Fork 990
/
Copy pathhandlePreviewToggles.ts
51 lines (45 loc) · 1.49 KB
/
handlePreviewToggles.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"use strict";
import { bold, red } from "colorette";
import * as experiments from "./experiments";
function errorOut(name?: string): void {
console.log(`${bold(red("Error:"))} Did not recognize preview feature ${bold(name || "")}`);
process.exit(1);
}
/**
* Implement --open-sesame and --close-sesame
*/
export function handlePreviewToggles(args: string[]): boolean {
const name = args[1];
const isValid = experiments.isValidExperiment(name);
if (args[0] === "--open-sesame") {
console.log(
`${bold("firebase --open-sesame")} is deprecated and wil be removed in a future ` +
`version. Use the new "experiments" family of commands, including ${bold(
"firebase experiments:enable",
)}`,
);
if (isValid) {
console.log(`Enabling experiment ${bold(name)} ...`);
experiments.setEnabled(name, true);
experiments.flushToDisk();
console.log("Experiment enabled!");
return process.exit(0);
}
errorOut(name);
} else if (args[0] === "--close-sesame") {
console.log(
`${bold("firebase --open-sesame")} is deprecated and wil be removed in a future ` +
`version. Use the new "experiments" family of commands, including ${bold(
"firebase experiments:disable",
)}`,
);
if (isValid) {
console.log(`Disabling experiment ${bold(name)}...`);
experiments.setEnabled(name, false);
experiments.flushToDisk();
return process.exit(0);
}
errorOut(name);
}
return false;
}