(
context: CreateNodesContextV2,
projectConfigurationFile: string,
createOptions: CreateNodesOptions = {},
)
| 9 | } from './types.js'; |
| 10 | |
| 11 | export async function normalizedCreateNodesV2Context( |
| 12 | context: CreateNodesContextV2, |
| 13 | projectConfigurationFile: string, |
| 14 | createOptions: CreateNodesOptions = {}, |
| 15 | ): Promise<NormalizedCreateNodesV2Context> { |
| 16 | const projectRoot = path.dirname(projectConfigurationFile); |
| 17 | |
| 18 | try { |
| 19 | const projectJson = JSON.parse( |
| 20 | (await readFile(projectConfigurationFile)).toString(), |
| 21 | ) as ProjectConfigurationWithName; |
| 22 | |
| 23 | const { targetName = CP_TARGET_NAME } = createOptions; |
| 24 | return { |
| 25 | ...context, |
| 26 | projectJson, |
| 27 | projectRoot, |
| 28 | createOptions: { ...createOptions, targetName }, |
| 29 | }; |
| 30 | } catch { |
| 31 | throw new Error( |
| 32 | `Error parsing project.json file ${projectConfigurationFile}.`, |
| 33 | ); |
| 34 | } |
| 35 | } |
no test coverage detected