mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
13 lines
518 B
TypeScript
13 lines
518 B
TypeScript
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
import { dirname, join } from "node:path";
|
|
import { prepareEnvironmentVariables } from "../docker/utils";
|
|
|
|
export const createEnvFile = (directory: string, env: string | null) => {
|
|
const envFilePath = join(dirname(directory), ".env");
|
|
if (!existsSync(dirname(envFilePath))) {
|
|
mkdirSync(dirname(envFilePath), { recursive: true });
|
|
}
|
|
const envFileContent = prepareEnvironmentVariables(env).join("\n");
|
|
writeFileSync(envFilePath, envFileContent);
|
|
};
|