Created
July 2, 2021 08:57
-
-
Save frankkoenigstein/31927d8dfc544b2c3977b46190fbf0bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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