(cli: string, workspaceFolder: string, options?: { cwd?: string; useBuildKit?: boolean; userDataFolder?: string; logLevel?: string; extraArgs?: string; prefix?: string; env?: NodeJS.ProcessEnv })
| 89 | } |
| 90 | |
| 91 | export async function devContainerUp(cli: string, workspaceFolder: string, options?: { cwd?: string; useBuildKit?: boolean; userDataFolder?: string; logLevel?: string; extraArgs?: string; prefix?: string; env?: NodeJS.ProcessEnv }): Promise<UpResult> { |
| 92 | const buildkitOption = (options?.useBuildKit ?? false) ? '' : ' --buildkit=never'; |
| 93 | const userDataFolderOption = (options?.userDataFolder ?? false) ? ` --user-data-folder=${options?.userDataFolder}` : ''; |
| 94 | const logLevelOption = (options?.logLevel ?? false) ? ` --log-level ${options?.logLevel}` : ''; |
| 95 | const extraArgs = (options?.extraArgs ?? false) ? ` ${options?.extraArgs}` : ''; |
| 96 | const prefix = (options?.prefix ?? false) ? `${options?.prefix} ` : ''; |
| 97 | const shellExecOptions = { cwd: options?.cwd, env: options?.env }; |
| 98 | const res = await shellExec(`${prefix}${cli} up --workspace-folder ${workspaceFolder}${buildkitOption}${userDataFolderOption}${extraArgs} ${logLevelOption}`, shellExecOptions); |
| 99 | const response = JSON.parse(res.stdout); |
| 100 | assert.equal(response.outcome, 'success'); |
| 101 | const { outcome, containerId, composeProjectName } = response as UpResult; |
| 102 | assert.ok(containerId, 'Container id not found.'); |
| 103 | return { outcome, containerId, composeProjectName, stderr: res.stderr }; |
| 104 | } |
| 105 | export async function devContainerDown(options: { containerId?: string | null; composeProjectName?: string | null; doNotThrow?: boolean }) { |
| 106 | if (options.containerId) { |
| 107 | await shellExec(`docker rm -f ${options.containerId}`, undefined, undefined, options.doNotThrow); |
no test coverage detected