(cliHost: CLIHost, workspace: Workspace | undefined, configFile: URI, mountWorkspaceGitRoot: boolean, mountGitWorktreeCommonDir: boolean, output: Log, consistency?: BindMountConsistency, overrideConfigFile?: URI)
| 80 | } |
| 81 | |
| 82 | export async function readDevContainerConfigFile(cliHost: CLIHost, workspace: Workspace | undefined, configFile: URI, mountWorkspaceGitRoot: boolean, mountGitWorktreeCommonDir: boolean, output: Log, consistency?: BindMountConsistency, overrideConfigFile?: URI) { |
| 83 | const documents = createDocuments(cliHost); |
| 84 | const content = await documents.readDocument(overrideConfigFile ?? configFile); |
| 85 | if (!content) { |
| 86 | return undefined; |
| 87 | } |
| 88 | const raw = jsonc.parse(content) as DevContainerConfig | undefined; |
| 89 | const updated = raw && updateFromOldProperties(raw); |
| 90 | if (!updated || typeof updated !== 'object' || Array.isArray(updated)) { |
| 91 | throw new ContainerError({ description: `Dev container config (${uriToFsPath(configFile, cliHost.platform)}) must contain a JSON object literal.` }); |
| 92 | } |
| 93 | const workspaceConfig = await getWorkspaceConfiguration(cliHost, workspace, updated, mountWorkspaceGitRoot, mountGitWorktreeCommonDir, output, consistency); |
| 94 | const substitute0: SubstituteConfig = value => substitute({ |
| 95 | platform: cliHost.platform, |
| 96 | localWorkspaceFolder: workspace?.rootFolderPath, |
| 97 | containerWorkspaceFolder: workspaceConfig.workspaceFolder, |
| 98 | configFile, |
| 99 | env: cliHost.env, |
| 100 | }, value); |
| 101 | const config: DevContainerConfig = substitute0(updated); |
| 102 | if (typeof config.workspaceFolder === 'string') { |
| 103 | workspaceConfig.workspaceFolder = config.workspaceFolder; |
| 104 | } |
| 105 | if ('workspaceMount' in config) { |
| 106 | workspaceConfig.workspaceMount = config.workspaceMount; |
| 107 | } |
| 108 | config.configFilePath = configFile; |
| 109 | return { |
| 110 | config: { |
| 111 | config, |
| 112 | raw: updated, |
| 113 | substitute: substitute0, |
| 114 | }, |
| 115 | workspaceConfig, |
| 116 | }; |
| 117 | } |
no test coverage detected