fix: clean up outdated sub-store.bundle.js

This commit is contained in:
Memory 2025-08-27 12:59:39 +08:00 committed by GitHub
parent 78ec7f9822
commit add4196dc5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,7 +22,7 @@ import {
defaultProfileConfig defaultProfileConfig
} from './template' } from './template'
import yaml from 'yaml' import yaml from 'yaml'
import { mkdir, writeFile, rm, readdir, cp, stat } from 'fs/promises' import { mkdir, writeFile, rm, readdir, cp, stat, rename } from 'fs/promises'
import { existsSync } from 'fs' import { existsSync } from 'fs'
import { exec } from 'child_process' import { exec } from 'child_process'
import { promisify } from 'util' import { promisify } from 'util'
@ -218,6 +218,19 @@ async function cleanup(): Promise<void> {
} }
} }
async function migrateSubStoreFiles(): Promise<void> {
const oldJsPath = path.join(mihomoWorkDir(), 'sub-store.bundle.js')
const newCjsPath = path.join(mihomoWorkDir(), 'sub-store.bundle.cjs')
if (existsSync(oldJsPath) && !existsSync(newCjsPath)) {
try {
await rename(oldJsPath, newCjsPath)
} catch (error) {
await initLogger.error('Failed to rename sub-store.bundle.js to sub-store.bundle.cjs', error)
}
}
}
async function migration(): Promise<void> { async function migration(): Promise<void> {
const { const {
siderOrder = [ siderOrder = [
@ -334,6 +347,7 @@ export async function initBasic(): Promise<void> {
await initDirs() await initDirs()
await initConfig() await initConfig()
await migration() await migration()
await migrateSubStoreFiles()
await initFiles() await initFiles()
await cleanup() await cleanup()
} }