clash-kit 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -2
- package/lib/commands/sub.js +6 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -15,8 +15,8 @@ const __filename = fileURLToPath(import.meta.url)
|
|
|
15
15
|
const __dirname = path.dirname(__filename)
|
|
16
16
|
|
|
17
17
|
// ---------------- 配置项 ----------------
|
|
18
|
-
const CLASH_BIN_PATH = path.join(__dirname, 'clash-kit') // 解压后的二进制文件路径
|
|
19
|
-
const CLASH_CONFIG_PATH = path.join(__dirname, 'config.yaml') // 配置文件路径
|
|
18
|
+
export const CLASH_BIN_PATH = path.join(__dirname, 'clash-kit') // 解压后的二进制文件路径
|
|
19
|
+
export const CLASH_CONFIG_PATH = path.join(__dirname, 'config.yaml') // 配置文件路径
|
|
20
20
|
|
|
21
21
|
async function checkPorts() {
|
|
22
22
|
try {
|
package/lib/commands/sub.js
CHANGED
|
@@ -4,6 +4,7 @@ import fs from 'fs'
|
|
|
4
4
|
import { fileURLToPath } from 'url'
|
|
5
5
|
import chalk from 'chalk'
|
|
6
6
|
import * as sub from '../subscription.js'
|
|
7
|
+
import { CLASH_BIN_PATH } from '../../index.js'
|
|
7
8
|
|
|
8
9
|
const __filename = fileURLToPath(import.meta.url)
|
|
9
10
|
const __dirname = path.dirname(__filename)
|
|
@@ -22,6 +23,11 @@ async function handleAddSubscription(url, name) {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export async function manageSub(options) {
|
|
26
|
+
// 检查 clash-kit 二进制文件是否存在
|
|
27
|
+
if (!fs.existsSync(CLASH_BIN_PATH)) {
|
|
28
|
+
return console.error(chalk.red('\n找不到 Clash.Meta 内核文件,请先运行 clash init 命令初始化内核!\n'))
|
|
29
|
+
}
|
|
30
|
+
|
|
25
31
|
if (options.add) {
|
|
26
32
|
if (!options.name) return console.error('错误: 添加订阅时必须指定名称 (-n)')
|
|
27
33
|
try {
|