Guest User

Untitled

a guest
Jun 19th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. const fs = require('fs');
  2.  
  3.  
  4. const mixinMap = {
  5. 'LimitMixin': 'limit',
  6. 'SdfsdMixin': 'sdfsd'
  7. };
  8.  
  9. const filePath = 'testfile.js';
  10.  
  11. let fileContent = fs.readFileSync(filePath);
  12. fileContent = replaceContent(fileContent.toString());
  13.  
  14. fs.writeFile(filePath, fileContent, (error) => {
  15. if (error) {
  16. console.log(error);
  17. }
  18.  
  19. console.log(`File ${filePath} succesfully written`);
  20. });
  21.  
  22. function replaceContent(content) {
  23. for (const item in mixinMap) {
  24. if (content.includes(item)) {
  25. const paramRegex = ` \\* @param {.+} \\[options.${mixinMap[item]}][\\s\\S]+?((?= \\* @)|(?= \\*\\/))`;
  26. content = content.replace(new RegExp(paramRegex, 'g'), '');
  27. }
  28. }
  29.  
  30. return content;
  31. }
  32.  
  33.  
  34. //ls -l -R | awk '{if ($2==1) print $9","}'
Add Comment
Please, Sign In to add comment