| 5 | const WS_FOLDER = './ts/src/pro/'; |
| 6 | |
| 7 | function processFile(fileContent) { |
| 8 | let fileSplit = fileContent.split('\n'); |
| 9 | |
| 10 | const newFile: string[] = []; |
| 11 | for (let i = 0; i < fileSplit.length; i++) { |
| 12 | |
| 13 | const currentLine = fileSplit[i]; |
| 14 | |
| 15 | const isSignatureRegex = /\s*async\s\w+/; |
| 16 | if (isSignatureRegex.test(currentLine)) { |
| 17 | const nextLine = fileSplit[i + 1]; |
| 18 | const isJSDocRegex = /\s*\/\*\*/; |
| 19 | if (isJSDocRegex.test(nextLine)) { |
| 20 | let jsDocLines = [nextLine]; |
| 21 | let j = i + 2; |
| 22 | while (fileSplit[j] && !/\s*\*\//.test(fileSplit[j])) { |
| 23 | jsDocLines.push(fileSplit[j]); |
| 24 | j++; |
| 25 | } |
| 26 | jsDocLines.push(fileSplit[j]); |
| 27 | // remove 1 level of identation from jsdoc |
| 28 | const spaces4 = ' '; |
| 29 | const spaces5 = ' '; |
| 30 | jsDocLines = jsDocLines.map((line, i) => (i == 0 ? spaces4 : spaces5) + line.trim()); |
| 31 | newFile.push(jsDocLines.join('\n')); |
| 32 | newFile.push(currentLine); |
| 33 | i = j; |
| 34 | } else { |
| 35 | newFile.push(currentLine); |
| 36 | } |
| 37 | } else { |
| 38 | newFile.push(currentLine); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | const updatedContent = newFile.join('\n'); |
| 43 | return updatedContent; |
| 44 | } |
| 45 | |
| 46 | |
| 47 | function main() { |