Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
| import { Plugin } from 'ts-migrate-server'; | |
| type Options = {}; | |
| const examplePluginText: Plugin<Options> = { | |
| name: 'example-plugin-text', | |
| async run({ text }) { | |
| // will add a console.log before each return statement | |
| const returnIndex = text.indexOf('return'); | |
| // eslint-disable-next-line no-template-curly-in-string | |
| const logBeforeReturnStatement = 'console.log(`args: ${arguments}`)\n'; | |
| if (returnIndex > -1) { | |
| const newText = | |
| text.substring(0, returnIndex) + logBeforeReturnStatement + text.substr(returnIndex); | |
| return newText; | |
| } | |
| return text; | |
| }, | |
| }; | |
| export default examplePluginText; |