return tree; const tsProject = new ts.Project({ manipulationSettings: { indentationText: ts.IndentationText.TwoSpaces, }, }); const tsFile = tsProject.addExistingSourceFile(mainFilePath); const bootstrapFunction = tsFile.getFunction('bootstrap'); const listenStatement = bootstrapFunction.getStatement(node => node.getText().includes('listen'), ); const setPrefixStatement = bootstrapFunction.getStatement(node => node.getText().includes('setGlobalPrefix'), ); if (!listenStatement || setPrefixStatement) { return tree; const listenExprIndex = listenStatement.getChildIndex(); bootstrapFunction.insertStatements( listenExprIndex, `app.setGlobalPrefix('api');`, ); tree.overwrite(mainFilePath, tsFile.getFullText()); return tree; };
return tree; const tsProject = new ts.Project({ manipulationSettings: { indentationText: ts.IndentationText.TwoSpaces, }, }); const tsFile = tsProject.addExistingSourceFile(mainFilePath); const bootstrapFunction = tsFile.getFunction('bootstrap'); const listenStatement = bootstrapFunction.getStatement(node => node.getText().includes('listen'), ); const setPrefixStatement = bootstrapFunction.getStatement(node => node.getText().includes('setGlobalPrefix'), ); if (!listenStatement || setPrefixStatement) { return tree; const listenExprIndex = listenStatement.getChildIndex(); bootstrapFunction.insertStatements( listenExprIndex, `app.setGlobalPrefix('api');`, ); tree.overwrite(mainFilePath, tsFile.getFullText()); return tree; };