mirror of
https://git.stupid.fish/teidesu/scripts.git
synced 2026-01-12 15:11:10 +11:00
chore: update public repo
This commit is contained in:
parent
7eaf8df8f0
commit
e75d7f7f29
25 changed files with 5364 additions and 0 deletions
10
utils/misc.ts
Normal file
10
utils/misc.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import 'dotenv/config'
|
||||
|
||||
export function getEnv(key: string): string
|
||||
export function getEnv<T>(key: string, parser: (value: string) => T): T
|
||||
export function getEnv<T>(key: string, parser?: (value: string) => T): T | string {
|
||||
const value = process.env[key]
|
||||
if (!value) throw new Error(`env variable ${key} not found`)
|
||||
if (!parser) return value
|
||||
return parser(value)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue