Files
HexaHost-GameCloud/scripts/run-with-env.mjs
2026-07-05 14:40:57 +02:00

26 lines
575 B
JavaScript

import { spawnSync } from 'node:child_process';
import { existsSync } from 'node:fs';
import { resolve } from 'node:path';
const root = resolve(import.meta.dirname, '..');
const envFile = resolve(root, '.env');
if (existsSync(envFile)) {
process.loadEnvFile(envFile);
}
const [command, ...args] = process.argv.slice(2);
if (!command) {
console.error('Usage: node scripts/run-with-env.mjs <command> [args...]');
process.exit(1);
}
const result = spawnSync(command, args, {
cwd: root,
stdio: 'inherit',
env: process.env,
});
process.exit(result.status ?? 1);