UNPKG

@testcontainers/gcloud

Version:
40 lines 1.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EmulatorFlagsManager = void 0; class EmulatorFlagsManager { flags = {}; /** * Adds flag as argument to emulator start command. * Adding same flag name twice replaces existing flag value. * @param name flag name. Must be set to non-empty string. May optionally contain -- prefix. * @param value flag value. May be empty string. * @returns this instance for chaining. */ withFlag(name, value) { if (!name) throw new Error("Flag name must be set."); if (name.startsWith("--")) this.flags[name] = value; else this.flags[`--${name}`] = value; return this; } flagToString(name, value) { return `${name}${value ? "=" + value : ""}`; } /** * * @returns string with all flag names and values, concatenated in same order they were added. */ expandFlags() { return `${Object.keys(this.flags).reduce((p, c) => p + " " + this.flagToString(c, this.flags[c]), "")}`; } /** * Clears all added flags. */ clearFlags() { this.flags = {}; } } exports.EmulatorFlagsManager = EmulatorFlagsManager; //# sourceMappingURL=emulator-flags-manager.js.map