From 255e132f98a49adb8c9e4d831f64df2c4180f190 Mon Sep 17 00:00:00 2001 From: lisonge Date: Mon, 25 Sep 2023 14:37:10 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 +++----- Template.md | 8 +++----- src/file.ts | 12 ++++++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 63bb8a2b..8d08ae90 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ # @gkd-kit/subscription -

- npm package -

+GKD 默认订阅规则 -搞快点 APP 默认订阅规则 +当前订阅为 APP 自带, 无需手动添加, 当前版本: v108 当前订阅文件已适配 204 个 APP, 共有 505 规则组 @@ -221,4 +219,4 @@ ## 感谢以下开发者的贡献 -![img](https://contrib.rocks/image?repo=gkd-kit/subscription) +![img](https://contrib.rocks/image?repo=gkd-kit/subscription&_v=--VERSION--) diff --git a/Template.md b/Template.md index 5c339485..3b2f0a4f 100644 --- a/Template.md +++ b/Template.md @@ -1,10 +1,8 @@ # @gkd-kit/subscription -

- npm package -

+GKD 默认订阅规则 -搞快点 APP 默认订阅规则 +当前订阅为 APP 自带, 无需手动添加, 当前版本: v--VERSION-- 当前订阅文件已适配 --APP_SIZE-- 个 APP, 共有 --GROUP_SIZE-- 规则组 @@ -16,4 +14,4 @@ ## 感谢以下开发者的贡献 -![img](https://contrib.rocks/image?repo=gkd-kit/subscription) +![img](https://contrib.rocks/image?repo=gkd-kit/subscription&_v=--VERSION--) diff --git a/src/file.ts b/src/file.ts index 66fc76a4..f4ce9135 100644 --- a/src/file.ts +++ b/src/file.ts @@ -30,15 +30,19 @@ export const writeConfig = async (fp: string, config: SubscriptionConfig) => { newConfig.version = oldConfig.version || 0; checkConfig(newConfig); + const hasUpdate = !_.isEqual(newConfig, oldConfig); + if (hasUpdate) { + newConfig.version++; + } + // update md await updateReadMeMd(newConfig); console.log('更新文档'); - if (_.isEqual(newConfig, oldConfig)) { - console.log('没有检测到规则变化,跳过更新'); + if (!hasUpdate) { + console.log('没有检测到规则变化,跳过更新JSON'); return; } - newConfig.version++; // keep json key sort by map const map = new Map(); @@ -288,7 +292,7 @@ export const updateReadMeMd = async (newConfig: SubscriptionConfig) => { .reduce((p, c) => p + (c.groups?.length || 0), 0) .toString(), ) + .replace('--VERSION--', (newConfig.version || 0).toString()) .replace('--APP_LIST--', appListText); - await fs.writeFile(process.cwd() + '/README.md', readMeMdText); };