From 8efdce73d1a1216e8ed05263d5c48649b37f2487 Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Mon, 6 Jul 2026 00:08:28 +0800 Subject: [PATCH] fix(versioning): improve staged files handling in updateVersion function --- packages/versioning/src/update-version.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/versioning/src/update-version.ts b/packages/versioning/src/update-version.ts index 5812980f..96382ffc 100644 --- a/packages/versioning/src/update-version.ts +++ b/packages/versioning/src/update-version.ts @@ -25,7 +25,10 @@ export function updateVersion(type: 'dev' | 'prod') { 'pnpm-lock.yaml', 'theme.toml', ] - const gitDiff: string = runCommand('git diff --cached --name-only') + const stagedFiles: string[] = runCommand('git diff --cached --name-only') + .split('\n') + .map(file => file.trim()) + .filter(Boolean) // consola.info( // 'Node.js:', @@ -39,7 +42,9 @@ export function updateVersion(type: 'dev' | 'prod') { consola.info(`The current branch is ${branch}, no need to update the FixIt version.`) process.exit(0) } - if (!match.some(item => gitDiff.includes(item))) { + if (!match.some(item => item.endsWith('/') + ? stagedFiles.some(file => file.startsWith(item)) + : stagedFiles.includes(item))) { consola.info('No need to update the FixIt version.') process.exit(0) } @@ -64,7 +69,7 @@ export function updateVersion(type: 'dev' | 'prod') { const lastVersion: string = versionMatch[0].slice(1) const newInitHtml: string = initHtml.replace(VERSION_RE, `v${latestVersion}`) - if (lastVersion === version && gitDiff.includes('layouts/_partials/init/index.html')) { + if (lastVersion === version && stagedFiles.includes('layouts/_partials/init/index.html')) { // After running `npm version` or manually modifying the version number, skip the update consola.info(`The FixIt version has been updated to v${lastVersion}.`) process.exit(0)