Skip to content

Commit

Permalink
add cli supports
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonation committed Apr 10, 2020
1 parent 7d7b111 commit a351ae3
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 5 deletions.
4 changes: 2 additions & 2 deletions bin/wechat-devtools
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
17 changes: 17 additions & 0 deletions bin/wechat-devtools-cli
Original file line number Diff line number Diff line change
@@ -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 "$@"
17 changes: 17 additions & 0 deletions tools/fix-cli
Original file line number Diff line number Diff line change
@@ -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);
12 changes: 9 additions & 3 deletions tools/update-wechat-devtools
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
3 changes: 3 additions & 0 deletions tools/wechat-devtools-cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require("../nwjs/package.nw/js/common/cli/index.js");

0 comments on commit a351ae3

Please sign in to comment.