UNPKG

@stryker-mutator/core

Version:

The extendable JavaScript mutation testing framework

34 lines 892 B
/** * A class that lets you manipulate env variables and reset them after a test */ export class EnvironmentVariableStore { constructor() { this.originals = Object.create(null); } store(key) { if (!(key in this.originals)) { this.originals[key] = process.env[key]; } } set(key, value) { this.store(key); process.env[key] = value; } unset(key) { this.store(key); delete process.env[key]; } restore() { Object.keys(this.originals).forEach((key) => { const value = this.originals[key]; if (value === undefined) { delete process.env[key]; } else { process.env[key] = value; } delete this.originals[key]; }); } } //# sourceMappingURL=environment-variable-store.js.map