diff --git a/fix-regex.js b/fix-regex.js index 8581a39..9b3e81e 100644 --- a/fix-regex.js +++ b/fix-regex.js @@ -8,9 +8,9 @@ const fs = require('fs') const filesToFix = [ - 'node_modules/@actions/github/node_modules/@octokit/request/dist-src/fetch-wrapper.js', - 'node_modules/@actions/github/node_modules/@octokit/request/dist-node/index.js', - 'node_modules/@actions/github/node_modules/@octokit/request/dist-web/index.js', + 'node_modules/@actions/github/node_modules/@octokit/request/dist-src/fetch-wrapper.js', + 'node_modules/@actions/github/node_modules/@octokit/request/dist-node/index.js', + 'node_modules/@actions/github/node_modules/@octokit/request/dist-web/index.js', ] process.stdout.write('šŸ”§ Applying regex fix for @octokit/request...\n') @@ -18,30 +18,30 @@ process.stdout.write('šŸ”§ Applying regex fix for @octokit/request...\n') let filesFixed = 0 for (const filePath of filesToFix) { - if (fs.existsSync(filePath)) { - try { - let content = fs.readFileSync(filePath, 'utf8') - const originalContent = content + if (fs.existsSync(filePath)) { + try { + let content = fs.readFileSync(filePath, 'utf8') + const originalContent = content - // Fix the problematic regex pattern - replace the end anchor version with the fixed version - content = content.replace(/charset=utf-8\$\//g, 'charset=utf-8/') + // Fix the problematic regex pattern - replace the end anchor version with the fixed version + content = content.replace(/^text\/|charset=utf-8$\//g, '/^(text\/|charset=utf-8)$/') - if (content !== originalContent) { - fs.writeFileSync(filePath, content, 'utf8') - process.stdout.write(`āœ… Fixed: ${filePath}\n`) - filesFixed++ - } else { - process.stdout.write(`ā„¹ļø No changes needed: ${filePath}\n`) - } - } catch (error) { - process.stderr.write(`āŒ Error fixing ${filePath}: ${error.message}\n`) + if (content !== originalContent) { + fs.writeFileSync(filePath, content, 'utf8') + process.stdout.write(`āœ… Fixed: ${filePath}\n`) + filesFixed++ + } else { + process.stdout.write(`ā„¹ļø No changes needed: ${filePath}\n`) + } + } catch (error) { + process.stderr.write(`āŒ Error fixing ${filePath}: ${error.message}\n`) + } + } else { + process.stdout.write(`āš ļø File not found: ${filePath}\n`) } - } else { - process.stdout.write(`āš ļø File not found: ${filePath}\n`) - } } process.stdout.write(`\nšŸŽ‰ Fix complete! ${filesFixed} files updated.\n`) if (filesFixed > 0) { - process.stdout.write('Run "npm run build:package" to rebuild with the fix.\n') + process.stdout.write('Run "npm run build:package" to rebuild with the fix.\n') }