mirror of
https://github.com/actions/add-to-project.git
synced 2025-12-12 21:17:11 +00:00
Fix regex pattern in @octokit/request files for correct operator precedence
This commit is contained in:
44
fix-regex.js
44
fix-regex.js
@@ -8,9 +8,9 @@
|
|||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
|
||||||
const filesToFix = [
|
const filesToFix = [
|
||||||
'node_modules/@actions/github/node_modules/@octokit/request/dist-src/fetch-wrapper.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-node/index.js',
|
||||||
'node_modules/@actions/github/node_modules/@octokit/request/dist-web/index.js',
|
'node_modules/@actions/github/node_modules/@octokit/request/dist-web/index.js',
|
||||||
]
|
]
|
||||||
|
|
||||||
process.stdout.write('🔧 Applying regex fix for @octokit/request...\n')
|
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
|
let filesFixed = 0
|
||||||
|
|
||||||
for (const filePath of filesToFix) {
|
for (const filePath of filesToFix) {
|
||||||
if (fs.existsSync(filePath)) {
|
if (fs.existsSync(filePath)) {
|
||||||
try {
|
try {
|
||||||
let content = fs.readFileSync(filePath, 'utf8')
|
let content = fs.readFileSync(filePath, 'utf8')
|
||||||
const originalContent = content
|
const originalContent = content
|
||||||
|
|
||||||
// Fix the problematic regex pattern - replace the end anchor version with the fixed version
|
// Fix the problematic regex pattern - replace the end anchor version with the fixed version
|
||||||
content = content.replace(/charset=utf-8\$\//g, 'charset=utf-8/')
|
content = content.replace(/^text\/|charset=utf-8$\//g, '/^(text\/|charset=utf-8)$/')
|
||||||
|
|
||||||
if (content !== originalContent) {
|
if (content !== originalContent) {
|
||||||
fs.writeFileSync(filePath, content, 'utf8')
|
fs.writeFileSync(filePath, content, 'utf8')
|
||||||
process.stdout.write(`✅ Fixed: ${filePath}\n`)
|
process.stdout.write(`✅ Fixed: ${filePath}\n`)
|
||||||
filesFixed++
|
filesFixed++
|
||||||
} else {
|
} else {
|
||||||
process.stdout.write(`ℹ️ No changes needed: ${filePath}\n`)
|
process.stdout.write(`ℹ️ No changes needed: ${filePath}\n`)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
process.stderr.write(`❌ Error fixing ${filePath}: ${error.message}\n`)
|
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`)
|
process.stdout.write(`\n🎉 Fix complete! ${filesFixed} files updated.\n`)
|
||||||
if (filesFixed > 0) {
|
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')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user