🌳
pt0/deployF/cliF/captureEpHelpAI.mts
1import { execFile } from 'child_process'
2import { promisify } from 'util'
5const aExecFile = promisify(execFile)
7export const captureEpHelp = async (ep: {importMetaUrl?: string}, { forceColor = false } = {}) => {
8 if (!ep?.importMetaUrl) return null
9 const absPath = getImportMetaUrlPath(ep.importMetaUrl)
10 const env = forceColor ? { ...process.env, FORCE_COLOR: '1' } : undefined
11 try {
12 const {stdout} = await aExecFile('node', [absPath, 'help'], {timeout: 15000, maxBuffer: 1024 * 1024, env})
13 return stdout.trim() || null
14 } catch (err: any) {
15 return err.stdout?.trim() || null
16 }