apply-patch.cjs 913 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env node
  2. const { execSync } = require('child_process');
  3. const fs = require('fs');
  4. const path = require('path');
  5. const patchFile = path.join(__dirname, 'templateHelper.patch');
  6. const targetFile = path.join(__dirname, '../../node_modules/jsdoc/lib/jsdoc/util/templateHelper.js');
  7. // Check if jsdoc is installed
  8. if (!fs.existsSync(targetFile)) {
  9. console.log('jsdoc not found, skipping patch');
  10. process.exit(0);
  11. }
  12. // Check if already patched
  13. const content = fs.readFileSync(targetFile, 'utf8');
  14. if (content.includes('buildMemberofIndex')) {
  15. console.log('✓ jsdoc already patched');
  16. process.exit(0);
  17. }
  18. // Apply the patch
  19. try {
  20. execSync(`patch -p0 < "${patchFile}"`, {
  21. cwd: path.join(__dirname, '../..'),
  22. stdio: 'pipe'
  23. });
  24. console.log('✓ Applied JSDoc performance patch (7.5x faster docs build)');
  25. } catch (err) {
  26. console.error('Failed to apply patch:', err.message);
  27. process.exit(1);
  28. }
粤ICP备19079148号