( id: string, type: "application" | "compose", filePath: string, )
| 145 | }; |
| 146 | |
| 147 | export const readPatchRepoFile = async ( |
| 148 | id: string, |
| 149 | type: "application" | "compose", |
| 150 | filePath: string, |
| 151 | ) => { |
| 152 | let serverId: string | null = null; |
| 153 | |
| 154 | if (type === "application") { |
| 155 | const application = await findApplicationById(id); |
| 156 | serverId = application.buildServerId || application.serverId; |
| 157 | } else { |
| 158 | const compose = await findComposeById(id); |
| 159 | serverId = compose.serverId; |
| 160 | } |
| 161 | const { PATCH_REPOS_PATH } = paths(!!serverId); |
| 162 | |
| 163 | const application = |
| 164 | type === "application" |
| 165 | ? await findApplicationById(id) |
| 166 | : await findComposeById(id); |
| 167 | |
| 168 | const repoPath = join(PATCH_REPOS_PATH, type, application.appName); |
| 169 | const fullPath = join(repoPath, filePath); |
| 170 | |
| 171 | const command = `cat "${fullPath}"`; |
| 172 | |
| 173 | if (serverId) { |
| 174 | const result = await execAsyncRemote(serverId, command); |
| 175 | return result.stdout; |
| 176 | } |
| 177 | |
| 178 | const result = await execAsync(command); |
| 179 | return result.stdout; |
| 180 | }; |
| 181 | |
| 182 | /** |
| 183 | * Clean all patch repos |
no test coverage detected