| 977 | } |
| 978 | |
| 979 | function parseEnvText(content: string): Record<string, string> { |
| 980 | const record: Record<string, string> = {}; |
| 981 | content.split(/\r?\n/u).forEach((rawLine) => { |
| 982 | const line = rawLine.trim(); |
| 983 | if (!line || line.startsWith('#')) { |
| 984 | return; |
| 985 | } |
| 986 | const separatorIndex = line.indexOf('='); |
| 987 | if (separatorIndex <= 0) { |
| 988 | return; |
| 989 | } |
| 990 | const key = line.slice(0, separatorIndex).trim(); |
| 991 | let value = line.slice(separatorIndex + 1).trim(); |
| 992 | if (!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(key)) { |
| 993 | return; |
| 994 | } |
| 995 | if ( |
| 996 | (value.startsWith('"') && value.endsWith('"')) |
| 997 | || (value.startsWith("'") && value.endsWith("'")) |
| 998 | ) { |
| 999 | value = value.slice(1, -1); |
| 1000 | } |
| 1001 | record[key] = value; |
| 1002 | }); |
| 1003 | return record; |
| 1004 | } |
| 1005 | |
| 1006 | async function runCommand( |
| 1007 | command: string, |