Skip to content

Commit 322de01

Browse files
committed
fix: cli使用异常 #147
1 parent 8c9eeed commit 322de01

File tree

5 files changed

+42
-9
lines changed

5 files changed

+42
-9
lines changed

CHANGELOG.MD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 1.06.2504010-2 / 2025-07-15
2+
- fix: cli使用异常。#147
3+
14
# 1.06.2504010-1 / 2025-07-05
25
- fix: 更新弹窗无法关闭。
36
- update: devtools to v1.06.2504010

bin/wechat-devtools-cli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
88
done
99
root_dir="$( cd -P "$( dirname "$SOURCE" )"/.. >/dev/null 2>&1 && pwd )"
1010

11-
cd $root_dir
11+
cd $root_dir/bin
1212

1313
export WECHAT_DEVTOOLS_DIR="$root_dir/nwjs"
1414
export APPDATA="$root_dir/nwjs"

res/scripts/cli.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
(() => {
2+
process.argv[0] = 'wechat-devtools-cli'
3+
process.env.USERPROFILE = require('os').homedir()
4+
Object.defineProperty(global, 'userDirPath', {
5+
set: function(value) {
6+
if (value.includes('AppData/Local')) {
7+
value = value.replace('AppData/Local', '.config')
8+
value = value.replace(/User Data\/.*?\//, '')
9+
// value = value.replace('~', require('os').homedir())
10+
}
11+
this._userDirPath = value
12+
},
13+
get: function() {
14+
return this._userDirPath
15+
}
16+
})
17+
// appPath
18+
Object.defineProperty(global, 'appPath', {
19+
set: function(value) {
20+
if (value.includes('.exe')) {
21+
value = value.replace('.exe', '')
22+
}
23+
this._appPath = value
24+
},
25+
get: function() {
26+
return this._appPath
27+
}
28+
})
29+
})();

res/scripts/entrance.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
(() => {
22
const http = require('http')
33
const originaleListen = http.Server.prototype.listen
4-
http.Server.prototype.listen = function(port) {
5-
if (port == 33233) {
6-
console.warn('block port of http server:', port)
4+
http.Server.prototype.listen = function(...args) {
5+
if (args[0] == 33233) {
6+
console.warn('block port of http server:', args[0])
77
return
88
}
9-
return originaleListen.apply(this, [port])
9+
return originaleListen.apply(this, args)
1010
}
1111
})();

tools/fix-cli.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ fi
1111

1212
cd "$NW_PACKAGE_DIR"
1313

14-
sed -i 's#AppData/Local/\${global.userDirName}/User Data/\${global.productHash}/Default#.config/\${global.userDirName}/Default#g' js/common/cli/index.js
15-
sed -i 's#USERPROFILE#HOME#g' js/common/cli/index.js
16-
sed -i 's#`./\${global.appname}.exe`#`./bin/\${global.appname}`#g' js/common/cli/index.js
17-
sed -i 's#,""));const T#,""));_.$0="wechat-devtools-cli";const T#' js/common/cli/index.js
14+
cd $root_dir/package.nw/js/common/cli
15+
cat $root_dir/res/scripts/cli.js > temp.js
16+
cat index.js >> temp.js
17+
rm index.js
18+
mv temp.js index.js

0 commit comments

Comments
 (0)