Skip to content

Commit 28ed09c

Browse files
committed
fixed: 修复更新脚本错误
1 parent 234e64e commit 28ed09c

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tlm",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"type": "module",
55
"description": "Terminal packages that support multiple translation platforms",
66
"main": "./dist/cli.js",
@@ -10,7 +10,7 @@
1010
"scripts": {
1111
"dev": "tsc-watch --onSuccess \"tsc-alias\"",
1212
"build": "tsc && tsc-alias",
13-
"postinstall": "node ./src/updated_config.js",
13+
"postinstall": "node ./updated-config.js",
1414
"test": "echo \"Error: no test specified\" && exit 1"
1515
},
1616
"exports": {
@@ -22,6 +22,7 @@
2222
"files": [
2323
"dist/",
2424
"config.json",
25+
"update-config.js",
2526
"README_EN.md"
2627
],
2728
"keywords": [
@@ -62,4 +63,4 @@
6263
"tsc-watch": "^6.2.0",
6364
"typescript": "^5.5.3"
6465
}
65-
}
66+
}

src/updated_config.js renamed to update-config.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,17 @@ import { fileURLToPath } from 'url';
44

55
const FILENAME = fileURLToPath(import.meta.url);
66
const DIRNAME = path.dirname(FILENAME);
7-
const CONFIG_PATH = path.join(DIRNAME, '../config.json');
7+
const CONFIG_PATH = path.join(DIRNAME, './config.json');
88
const TLMRC = path.join(process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'], '.tlmrc.json');
99

10-
1110
try {
12-
// 直接读取配置文件内容
1311
let config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf8'));
14-
1512
try {
16-
// 尝试读取 tlmrc 文件,如果存在则合并配置
1713
const localConfig = JSON.parse(fs.readFileSync(TLMRC, 'utf8'));
1814
Object.assign(config, localConfig);
1915
} catch (err) {
20-
// 如果 tlmrc 文件不存在,则忽略错误
2116
console.log('No existing tlmrc file found.');
2217
}
23-
24-
// 写入或更新 tlmrc 文件
2518
fs.writeFileSync(TLMRC, JSON.stringify(config, null, 2), 'utf8');
2619
console.log('Configuration updated successfully.');
2720
} catch (err) {

0 commit comments

Comments
 (0)