1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 01:03:35 +00:00

[EC-473] Add feature flags to common code (#3324)

This commit is contained in:
Thomas Rittson
2022-08-26 13:00:14 +10:00
committed by GitHub
parent aed78a5b61
commit 90137936fa
10 changed files with 261 additions and 114 deletions

View File

@@ -1,5 +1,27 @@
// Remove this linter hint if any flags exist
// eslint-disable-next-line @typescript-eslint/ban-types
export type Flags = {};
import {
flagEnabled as baseFlagEnabled,
devFlagEnabled as baseDevFlagEnabled,
devFlagValue as baseDevFlagValue,
SharedFlags,
SharedDevFlags,
} from "@bitwarden/common/misc/flags";
export type FlagName = keyof Flags;
// required to avoid linting errors when there are no flags
/* eslint-disable-next-line @typescript-eslint/ban-types */
export type Flags = {} & SharedFlags;
// required to avoid linting errors when there are no flags
/* eslint-disable-next-line @typescript-eslint/ban-types */
export type DevFlags = {} & SharedDevFlags;
export function flagEnabled(flag: keyof Flags): boolean {
return baseFlagEnabled<Flags>(flag);
}
export function devFlagEnabled(flag: keyof DevFlags) {
return baseDevFlagEnabled<DevFlags>(flag);
}
export function devFlagValue(flag: keyof DevFlags) {
return baseDevFlagValue(flag);
}

View File

@@ -13,8 +13,6 @@ import { FolderView } from "@bitwarden/common/models/view/folderView";
import { Response } from "@bitwarden/node/cli/models/response";
import { MessageResponse } from "@bitwarden/node/cli/models/response/messageResponse";
import { FlagName, Flags } from "./flags";
export class CliUtils {
static writeLn(s: string, finalLine = false, error = false) {
const stream = error ? process.stderr : process.stdout;
@@ -253,18 +251,4 @@ export class CliUtils {
static convertBooleanOption(optionValue: any) {
return optionValue || optionValue === "" ? true : false;
}
static flagEnabled(flag: FlagName) {
return this.flags[flag] == null || this.flags[flag];
}
private static get flags(): Flags {
const envFlags = process.env.FLAGS;
if (typeof envFlags === "string") {
return JSON.parse(envFlags) as Flags;
} else {
return envFlags as Flags;
}
}
}