( rootDir: string, extConfigName: string, extConfigFilePath: string, )
| 96 | type ExtConfigPairs = Pick<AppConfig, 'extConfigType' | 'extConfigName' | 'extConfigFilePath' | 'extConfig'>; |
| 97 | |
| 98 | async function loadExtConfigTS( |
| 99 | rootDir: string, |
| 100 | extConfigName: string, |
| 101 | extConfigFilePath: string, |
| 102 | ): Promise<ExtConfigPairs> { |
| 103 | try { |
| 104 | const tsPath = resolveNode(rootDir, 'typescript'); |
| 105 | |
| 106 | if (!tsPath) { |
| 107 | fatal( |
| 108 | 'Could not find installation of TypeScript.\n' + |
| 109 | `To use ${c.strong(extConfigName)} files, you must install TypeScript in your project, e.g. w/ ${c.input( |
| 110 | 'npm install -D typescript', |
| 111 | )}`, |
| 112 | ); |
| 113 | } |
| 114 | |
| 115 | const ts = require(tsPath); // eslint-disable-line @typescript-eslint/no-var-requires |
| 116 | const extConfigObject = requireTS(ts, extConfigFilePath) as any; |
| 117 | const extConfig = extConfigObject.default ? await extConfigObject.default : extConfigObject; |
| 118 | |
| 119 | return { |
| 120 | extConfigType: 'ts', |
| 121 | extConfigName, |
| 122 | extConfigFilePath: extConfigFilePath, |
| 123 | extConfig, |
| 124 | }; |
| 125 | } catch (e: any) { |
| 126 | if (!isFatal(e)) { |
| 127 | fatal(`Parsing ${c.strong(extConfigName)} failed.\n\n${e.stack ?? e}`); |
| 128 | } |
| 129 | |
| 130 | throw e; |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | async function loadExtConfigJS( |
| 135 | rootDir: string, |
no test coverage detected