|
| 1 | +import { readFileSync, writeFileSync } from 'node:fs'; |
| 2 | + |
| 3 | +function migrateUseSingle() { |
| 4 | + const filePath = 'src/select-input/useSingle.tsx'; |
| 5 | + let content = readFileSync(filePath, 'utf8'); |
| 6 | + if (content.includes('const instance = getCurrentInstance();')) { |
| 7 | + content = content.replace('const instance = getCurrentInstance();', 'const instance = getCurrentInstance().proxy;'); |
| 8 | + content = content.replaceAll('instance.emit', 'instance.$emit'); |
| 9 | + writeFileSync(filePath, content, 'utf8'); |
| 10 | + } |
| 11 | +} |
| 12 | +function migrateUseOverlayInnerStyle() { |
| 13 | + const filePath = 'src/select-input/useOverlayInnerStyle.ts'; |
| 14 | + let content = readFileSync(filePath, 'utf8'); |
| 15 | + if (content.includes('const instance = getCurrentInstance();')) { |
| 16 | + content = content.replace('const instance = getCurrentInstance();', 'const instance = getCurrentInstance().proxy;'); |
| 17 | + content = content.replaceAll('instance.emit', 'instance.$emit'); |
| 18 | + writeFileSync(filePath, content, 'utf8'); |
| 19 | + } |
| 20 | +} |
| 21 | +function migrateSelectInput() { |
| 22 | + const filePath = 'src/select-input/select-input.tsx'; |
| 23 | + let content = readFileSync(filePath, 'utf8'); |
| 24 | + if (content.includes('setup(props: TdSelectInputProps')) { |
| 25 | + content = content.replace('setup(props: TdSelectInputProps', 'setup(props'); |
| 26 | + writeFileSync(filePath, content, 'utf8'); |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +export default function () { |
| 31 | + migrateSelectInput(); |
| 32 | + migrateUseSingle(); |
| 33 | + migrateUseOverlayInnerStyle(); |
| 34 | +} |
0 commit comments