MCPcopy
hub / github.com/ionic-team/capacitor / loadExtConfigTS

Function loadExtConfigTS

cli/src/config.ts:98–132  ·  view source on GitHub ↗
(
  rootDir: string,
  extConfigName: string,
  extConfigFilePath: string,
)

Source from the content-addressed store, hash-verified

96type ExtConfigPairs = Pick<AppConfig, 'extConfigType' | 'extConfigName' | 'extConfigFilePath' | 'extConfig'>;
97
98async 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
134async function loadExtConfigJS(
135 rootDir: string,

Callers 1

loadExtConfigFunction · 0.85

Calls 4

resolveNodeFunction · 0.90
fatalFunction · 0.90
requireTSFunction · 0.90
isFatalFunction · 0.90

Tested by

no test coverage detected