From add4196dc5e0003cac9c30ab3bd85c70cf616b03 Mon Sep 17 00:00:00 2001 From: Memory <134070804+Memory2314@users.noreply.github.com> Date: Wed, 27 Aug 2025 12:59:39 +0800 Subject: [PATCH] fix: clean up outdated sub-store.bundle.js --- src/main/utils/init.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/utils/init.ts b/src/main/utils/init.ts index 709366d..2d0986d 100644 --- a/src/main/utils/init.ts +++ b/src/main/utils/init.ts @@ -22,7 +22,7 @@ import { defaultProfileConfig } from './template' 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 { exec } from 'child_process' import { promisify } from 'util' @@ -218,6 +218,19 @@ async function cleanup(): Promise { } } +async function migrateSubStoreFiles(): Promise { + 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 { const { siderOrder = [ @@ -334,6 +347,7 @@ export async function initBasic(): Promise { await initDirs() await initConfig() await migration() + await migrateSubStoreFiles() await initFiles() await cleanup() }