()
| 1034 | |
| 1035 | let version: string |
| 1036 | export const getVersion: () => Promise<{ version: string }> = async () => { |
| 1037 | if (version != null) return { version } |
| 1038 | |
| 1039 | const checkPaths = [ |
| 1040 | path.join(__dirname, '..', 'package.json'), |
| 1041 | path.join(__dirname, '..', '..', 'package.json'), |
| 1042 | path.join(__dirname, '..', '..', '..', 'package.json'), |
| 1043 | path.join(__dirname, '..', '..', '..', '..', 'package.json'), |
| 1044 | path.join(__dirname, '..', '..', '..', '..', '..', 'package.json') |
| 1045 | ] |
| 1046 | for (const checkPath of checkPaths) { |
| 1047 | try { |
| 1048 | const content = await fs.promises.readFile(checkPath, 'utf8') |
| 1049 | const parsedContent = JSON.parse(content) |
| 1050 | version = parsedContent.version |
| 1051 | return { version } |
| 1052 | } catch { |
| 1053 | continue |
| 1054 | } |
| 1055 | } |
| 1056 | |
| 1057 | throw new Error('None of the package.json paths could be parsed') |
| 1058 | } |
| 1059 | |
| 1060 | /** |
| 1061 | * Map Ext to InputField |
no test coverage detected