Skip to content

Instantly share code, notes, and snippets.

@frankkoenigstein
Created July 2, 2021 08:57
Show Gist options
  • Save frankkoenigstein/31927d8dfc544b2c3977b46190fbf0bb to your computer and use it in GitHub Desktop.
Save frankkoenigstein/31927d8dfc544b2c3977b46190fbf0bb to your computer and use it in GitHub Desktop.
const path = require('path');
const ts = require('typescript');
const controlFactoryPath = path.join(__dirname, '..', 'src/core/manager/guiManager/ControlFactory.ts');
const program = ts.createProgram([controlFactoryPath], {});
const sourceFile = program.getSourceFile(controlFactoryPath);
let controlMap: string[];
const analyseNode = (node) => {
if (node.kind === ts.SyntaxKind.VariableDeclaration && 'controlMap' === node?.name?.text) {
controlMap = node.initializer.properties.map((node) => node.name.text);
return;
}
ts.forEachChild(node, analyseNode);
};
ts.forEachChild(sourceFile, analyseNode);
console.log(controlMap);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment