You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
719 B
30 lines
719 B
|
1 month ago
|
import fs from 'node:fs'
|
||
|
|
import path from 'node:path'
|
||
|
|
|
||
|
|
const target = path.resolve(
|
||
|
|
process.cwd(),
|
||
|
|
'node_modules/@dcloudio/vite-plugin-uni/dist/configureServer/easycom.js',
|
||
|
|
)
|
||
|
|
|
||
|
|
if (!fs.existsSync(target)) {
|
||
|
|
process.exit(0)
|
||
|
|
}
|
||
|
|
|
||
|
|
const source = fs.readFileSync(target, 'utf8')
|
||
|
|
const oldCode = "const refreshEasycom = uni_shared_1.debounce(refresh, 100);"
|
||
|
|
const newCode = `const refreshEasycom = uni_shared_1.debounce(refresh, 100, {
|
||
|
|
clearTimeout,
|
||
|
|
setTimeout,
|
||
|
|
});`
|
||
|
|
|
||
|
|
if (source.includes(newCode)) {
|
||
|
|
process.exit(0)
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!source.includes(oldCode)) {
|
||
|
|
process.exit(0)
|
||
|
|
}
|
||
|
|
|
||
|
|
fs.writeFileSync(target, source.replace(oldCode, newCode), 'utf8')
|
||
|
|
console.log('[patch-uni] patched easycom debounce timers')
|