You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

25 lines
557 B

import assert from "assert";
import { readFile } from "fs/promises";
import { readFileSync } from "fs";
/**
* Fetch an environment variable
*/
export function env(variable: string, throwIfNotFound = true) {
let value = process.env[variable];
if (throwIfNotFound) {
assert(value !== undefined);
}
return <string>value;
}
/**
* Fetch a secret from a file
*/
export async function secret(path: string) {
return (await readFile(path)).toString().trim();
}
export function secretSync(path: string) {
return readFileSync(path).toString().trim();
}