UNPKG

@dotenc/cli

Version:

🔐 Secure, encrypted environment variables that live in your codebase

11 lines (10 loc) 398 B
import { existsSync } from "node:fs"; import path from "node:path"; import { encrypt } from "./crypto.js"; export const createEnvironment = async (name, key) => { const filePath = path.join(process.cwd(), `.env.${name}.enc`); if (existsSync(filePath)) { throw new Error(`Environment "${name}" already exists.`); } await encrypt(key, `# ${name} environment\n`, filePath); };