permitir generar solo algunos secretos
This commit is contained in:
parent
505178ec2f
commit
2a39aeb94b
1 changed files with 9 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
|||
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { exists } from "./better-api";
|
||||
|
||||
const secretsFileName = (name: string) => join("secrets", name + ".json");
|
||||
export function loadSecretsFile<T>(name: string): () => Promise<T> {
|
||||
|
@ -15,8 +16,13 @@ export function generateSecretsFile<T>(
|
|||
return async () => {
|
||||
const secrets = await generate();
|
||||
await mkdir("secrets", { recursive: true });
|
||||
await writeFile(secretsFileName(name), JSON.stringify(secrets, null, 2), {
|
||||
flag: "wx",
|
||||
});
|
||||
const fileName = secretsFileName(name);
|
||||
if (await exists(fileName)) {
|
||||
console.warn(`${fileName} ya existe, salteando..`);
|
||||
} else {
|
||||
await writeFile(fileName, JSON.stringify(secrets, null, 2), {
|
||||
flag: "wx",
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue