Env follow up (#231)

* Create the env file only if not empty

* Update

* Check some fs operation to async
This commit is contained in:
Louis Lam
2023-12-04 18:40:37 +08:00
committed by GitHub
parent 0df3fee3f4
commit 793a9de50d
6 changed files with 48 additions and 15 deletions

View File

@@ -5,6 +5,7 @@ import { log } from "./log";
import { ERROR_TYPE_VALIDATION } from "./util-common";
import { R } from "redbean-node";
import { verifyPassword } from "./password-hash";
import fs from "fs";
export interface JWTDecoded {
username : string;
@@ -82,3 +83,9 @@ export async function doubleCheckPassword(socket : DockgeSocket, currentPassword
return user;
}
export function fileExists(file : string) {
return fs.promises.access(file, fs.constants.F_OK)
.then(() => true)
.catch(() => false);
}