14 lines
755 B
TypeScript
14 lines
755 B
TypeScript
import { readFile } from 'node:fs/promises';
|
|
import { resolve } from 'node:path';
|
|
|
|
/** adapter-node copies public assets to build/client; Vite serves static in development. */
|
|
export async function agentReleaseAsset(file: 'install.sh' | 'ec-agent.py' | 'ec-agent-update.py' | 'manifest.json'): Promise<string> {
|
|
// A prior production build must never shadow a freshly packaged development release.
|
|
if (process.env.NODE_ENV === 'development') return readFile(resolve('static/agent', file), 'utf8');
|
|
try { return await readFile(resolve('build/client/agent', file), 'utf8'); }
|
|
catch (cause) {
|
|
if ((cause as NodeJS.ErrnoException).code !== 'ENOENT') throw cause;
|
|
return readFile(resolve('static/agent', file), 'utf8');
|
|
}
|
|
}
|