MCPcopy Index your code
hub / github.com/subquery/subql / fromFile

Method fromFile

packages/node-core/src/configure/NodeConfig.ts:105–119  ·  view source on GitHub ↗
(filePath: string, configFromArgs?: Partial<IConfig>, isTest?: boolean)

Source from the content-addressed store, hash-verified

103 protected readonly _isTest: boolean;
104
105 static fromFile(filePath: string, configFromArgs?: Partial<IConfig>, isTest?: boolean): NodeConfig {
106 if (!fs.existsSync(filePath)) {
107 throw new Error(`Load config from file ${filePath} is not exist`);
108 }
109 let configFromFile: unknown;
110 try {
111 configFromFile = loadFromJsonOrYaml(filePath);
112 } catch (e) {
113 logger.error(`failed to load config file, ${e}`);
114 throw e;
115 }
116
117 const config = assign(configFromFile, configFromArgs) as IConfig;
118 return new NodeConfig(config, isTest);
119 }
120
121 static rebaseWithArgs(config: NodeConfig, configFromArgs?: Partial<IConfig>): NodeConfig {
122 const _config = assign({}, (config as any)._config, configFromArgs);

Callers 2

registerAppFunction · 0.80
NodeConfig.spec.tsFile · 0.80

Calls 3

loadFromJsonOrYamlFunction · 0.90
assignFunction · 0.90
errorMethod · 0.45

Tested by

no test coverage detected