(source: string)
| 71 | } |
| 72 | |
| 73 | async function readConfigSource(source: string): Promise<PackConfig> { |
| 74 | let raw = ""; |
| 75 | |
| 76 | if (isHttpUrl(source)) { |
| 77 | const response = await fetch(source); |
| 78 | if (!response.ok) { |
| 79 | throw new Error( |
| 80 | `Failed to download config: ${response.status} ${response.statusText}`, |
| 81 | ); |
| 82 | } |
| 83 | raw = await response.text(); |
| 84 | } else { |
| 85 | const filePath = path.resolve(source); |
| 86 | raw = fs.readFileSync(filePath, "utf-8"); |
| 87 | } |
| 88 | |
| 89 | const parsed = JSON.parse(raw) as unknown; |
| 90 | validateConfigShape(parsed, source); |
| 91 | return parsed; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Copy templates/start.sh and templates/start.bat to workDir. |
no test coverage detected