(path: string | undefined)
| 83 | } |
| 84 | |
| 85 | export async function getRawJson(path: string | undefined): Promise<any> { |
| 86 | if (!path) { |
| 87 | return {}; |
| 88 | } |
| 89 | const fileExists: boolean = await checkFileExists(path); |
| 90 | if (!fileExists) { |
| 91 | return {}; |
| 92 | } |
| 93 | |
| 94 | const fileContents: string = await readFileText(path); |
| 95 | let rawElement: any = {}; |
| 96 | try { |
| 97 | rawElement = jsonc.parse(fileContents, undefined, true); |
| 98 | } catch { |
| 99 | throw new Error(failedToParseJson); |
| 100 | } |
| 101 | return rawElement; |
| 102 | } |
| 103 | |
| 104 | // This function is used to stringify the rawPackageJson. |
| 105 | // Do not use with util.packageJson or else the expanded |
nothing calls this directly
no test coverage detected