From f4440dc5446d1176d9dabe957acf6ba4830bb35f Mon Sep 17 00:00:00 2001 From: biaov Date: Tue, 28 May 2024 19:30:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ⚙️ 更新 `auto check -u` 命令运行后还输出更新前日志 - ⚙️ 更新依赖版本 --- package.json | 6 +++--- src/commander/commands/check.ts | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 16d7457..98ec794 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mine-auto-cli", "private": false, - "version": "2.4.2", + "version": "2.4.3", "exports": "./dist/index.js", "main": "./dist/index.js", "type": "module", @@ -52,7 +52,7 @@ ], "dependencies": { "chalk": "^5.3.0", - "commander": "^12.0.0", + "commander": "^12.1.0", "js-yaml": "^4.1.0", "log-symbols": "^6.0.0", "ora": "^8.0.1", @@ -71,4 +71,4 @@ "typescript": "^5.4.5", "vite": "^5.2.11" } -} +} \ No newline at end of file diff --git a/src/commander/commands/check.ts b/src/commander/commands/check.ts index 2659cb9..ff2951b 100644 --- a/src/commander/commands/check.ts +++ b/src/commander/commands/check.ts @@ -176,6 +176,7 @@ const simplifyUpgrade = async ({ update }: Record) => { if (!existsSync(packagePath)) return error('package.json 文件不存在') const newUpdate = update || userConfig.check + const packageJsonString = readFileSync(packagePath).toString() const packageJson: Record = JSON.parse(packageJsonString) const keys = ['dependencies', 'devDependencies', 'optionalDependencies'] @@ -204,12 +205,12 @@ const simplifyUpgrade = async ({ update }: Record) => { writeFileSync(packagePath, JSON.stringify(newPackages, null, 2)) success('文件 package.json 已更新') info() + } else { + /** + * 输出包信息 + */ + outVersionLog(versionLogs) } - - /** - * 输出包信息 - */ - outVersionLog(versionLogs) } program.command('check').option('-u, --update', `更新 package.json 依赖内容`, false).description('升级 package.json 依赖版本').action(simplifyUpgrade)