fix(ci): lazy-load dotenv in cli.mjs for deploy cooldown

vercel-deploy-cooldown.mjs only needs dieWithLabel from cli.mjs, but the
module eagerly imported dotenv. The deploy job runs the cooldown check
before pnpm install, so Node failed with ERR_MODULE_NOT_FOUND.

Require dotenv inside loadCliEnv() so lightweight CI steps can import
dieWithLabel without node_modules.
This commit is contained in:
Cursor Agent 2026-08-01 14:13:10 +00:00
parent ced9441fee
commit dcce160a4d
No known key found for this signature in database

View file

@ -8,9 +8,10 @@
*/
import { createHash } from 'node:crypto'
import { access, mkdir, readFile, writeFile } from 'node:fs/promises'
import { createRequire } from 'node:module'
import { dirname, join } from 'node:path'
import { config as loadEnv } from 'dotenv'
const require = createRequire(import.meta.url)
/** Labelled `die` factory: `dieWithLabel('seed:tse')` → the script's `die`. */
export const dieWithLabel = (label) => (message) => {
@ -22,6 +23,7 @@ export const sha256Hex = (buffer) => createHash('sha256').update(buffer).digest(
/** The dotenv preamble every DB-touching script needs (.env.local wins over .env). */
export const loadCliEnv = () => {
const { config: loadEnv } = require('dotenv')
loadEnv({ path: '.env.local' })
loadEnv({ path: '.env' })
}