MCPcopy Create free account
hub / github.com/subquery/subql / loadChainTypes

Function loadChainTypes

packages/node/src/utils/project.ts:64–79  ·  view source on GitHub ↗
(file: string, projectRoot: string)

Source from the content-addressed store, hash-verified

62}
63
64export function loadChainTypes(file: string, projectRoot: string): unknown {
65 const { ext } = path.parse(file);
66 const filePath = path.resolve(projectRoot, file);
67 if (fs.existsSync(filePath)) {
68 if (ext === '.js' || ext === '.cjs') {
69 //load can be self contained js file, or js depend on node_module which will require project root
70 return loadChainTypesFromJs(filePath, projectRoot);
71 } else if (ext === '.yaml' || ext === '.yml' || ext === '.json') {
72 return loadFromJsonOrYaml(filePath);
73 } else {
74 throw new Error(`Extension ${ext} not supported`);
75 }
76 } else {
77 throw new Error(`Load from file ${file} not exist`);
78 }
79}
80
81export function loadChainTypesFromJs(
82 filePath: string,

Callers 1

getChainTypesFunction · 0.85

Calls 2

loadFromJsonOrYamlFunction · 0.90
loadChainTypesFromJsFunction · 0.85

Tested by

no test coverage detected