-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(globals, utils): removes globals; keep environmentals and mo…
…ves it to utils
- Loading branch information
Showing
9 changed files
with
28 additions
and
205 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* eslint-disable @typescript-eslint/explicit-function-return-type */ | ||
import { TEnvironmental, OWNED_ENV_KEY } from '~/constants'; | ||
import { IOfType } from '~/types'; | ||
|
||
const locals = {} as IOfType<string>; | ||
|
||
/** | ||
* Used for state preservation for different kpo instances AND children | ||
* processes. Will only pollute `process.env` if the process is kpo owned, | ||
* that is, if `process.env[OWNED_ENV_KEY]` is set. | ||
*/ | ||
export default function environmentals(key: TEnvironmental) { | ||
const vars = process.env[OWNED_ENV_KEY] ? process.env : locals; | ||
|
||
return { | ||
get(): string | void { | ||
return vars[key] || undefined; | ||
}, | ||
set(value?: string): void { | ||
vars[key] = value || undefined; | ||
} | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.