INNER CODE UNIT · TypeScript
methodContent
maciejtreder/ng-toolkit · schematics/_utils/index.ts:264
let methodContent = fileContent.substr(startCut, methodLength - 2);
return methodContent;
} else {
return null;
}
}
export function addMethod(tree: Tree, filePath: string, body: string): void {
const sourceText = getFileContent(tree, filePath);
let changePos;
const changeRecorder = tree.beginUpdate(filePath);
if (body.indexOf('constructor') >= 0 || body.indexOf('public') >= 0) {
let match = sourceText.match(/(?:export|) class.*?{[\s\S]*?((?:constructor|public|private|)[\w\s]*?\()/);
if (match) {
changePos = (match['index'] || 0) + match[0].length - match[1].length;