diff --git a/bin/wechat-devtools b/bin/wechat-devtools index ae8e5e0..068c93b 100755 --- a/bin/wechat-devtools +++ b/bin/wechat-devtools @@ -12,6 +12,6 @@ cd $APPDATA/.. export WECHAT_DEVTOOLS_DIR="$DIR/../nwjs" export APPDATA="$DIR/../nwjs" -export PATH="$DIR/../nwjs:$PATH" +export PATH="$DIR/../node/bin:$DIR/../nwjs:$PATH" -LANG=zh_CN exec "$DIR"/../nwjs/nw "$@" --load-extension="$DIR"/../nwjs/package.nw/js/ideplugin "$@" +LANG=zh_CN.UTF-8 exec "$DIR"/../nwjs/nw --load-extension="$DIR"/../nwjs/package.nw/js/ideplugin "$@" diff --git a/bin/wechat-devtools-cli b/bin/wechat-devtools-cli new file mode 100755 index 0000000..c4dc103 --- /dev/null +++ b/bin/wechat-devtools-cli @@ -0,0 +1,17 @@ +#! /bin/bash + +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" + +cd $APPDATA/.. + +export WECHAT_DEVTOOLS_DIR="$DIR/../nwjs" +export APPDATA="$DIR/../nwjs" +export PATH="$DIR/../node/bin:$DIR/../nwjs:$PATH" + +$DIR/../tools/wechat-devtools-cli "$@" diff --git a/tools/fix-cli b/tools/fix-cli new file mode 100755 index 0000000..c6daa29 --- /dev/null +++ b/tools/fix-cli @@ -0,0 +1,17 @@ +#!/usr/bin/env mew_js + +@info("Patching CLI command"); + +const rootDir = @.fs.dirname(__dirname); + +let cli = @.fs.readFile.sync(@path(rootDir, "package.nw/js/common/cli/index.js"), "utf8"); + +cli = cli.replace(/USERPROFILE/g, "HOME"); +cli = cli.replace(/AppData\/Local\/\$\{global\.userDirName\}\/User Data/g, + ".config/${global.userDirName}"); +cli = cli.replace(/`\.\/\$\{global.appname\}\.exe`/g, + "require(\"path\").join(__dirname, \"../../../../bin/wechat-devtools\")"); +cli = cli.replace(/"\.\.\/\.\.\/\.\.\/\.\.\/resources_win\/nw\/x64\/nw.exe"/g, + "\"../../../../nwjs/nw\""); + +@.fs.writeFile.sync(@path(rootDir, "package.nw/js/common/cli/index.js"), cli); \ No newline at end of file diff --git a/tools/update-wechat-devtools b/tools/update-wechat-devtools index 6f4cf02..0894279 100755 --- a/tools/update-wechat-devtools +++ b/tools/update-wechat-devtools @@ -103,22 +103,28 @@ const packageDir = "$APPDATA/Tencent/微信开发者工具/package.nw"; }).then(function () { - @info("Fixing wechat-devtools package name"); + @info("Patching wechat-devtools package name"); @.task.execute(@path(__dirname, "fix-package-name"), [], false, this.test); }).then(function () { - @info("Fix wechat-devtools editor font"); + @info("Patching wechat-devtools editor font"); @.task.execute(@path(__dirname, "fix-editor-font"), [], false, this.test); }).then(function () { - @info("Fix wechat-devtools editor selection autocopy"); + @info("Patching wechat-devtools editor selection autocopy"); @.task.execute(@path(__dirname, "fix-selection-copy"), [], false, this.test); +}).then(function () { + + @info("Patching wechat-devtools CLI supports"); + + @.task.execute(@path(__dirname, "fix-cli"), [], false, this.test); + }).then(function () { @info("Rebuilding wechat-devtools node modules"); diff --git a/tools/wechat-devtools-cli b/tools/wechat-devtools-cli new file mode 100755 index 0000000..f063d05 --- /dev/null +++ b/tools/wechat-devtools-cli @@ -0,0 +1,3 @@ +#!/usr/bin/env node + +require("../nwjs/package.nw/js/common/cli/index.js");