commit a8d015c0abd53f81daf2ecce28d8f8e621cd84e0 Author: Minun Date: Tue Feb 4 04:34:34 2020 +0800 basically implement all wechat-devtools build scripts diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..952f394 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +nwjs/ +node/ +package.nw/ +cache/ +tmp/ diff --git a/bin/wechat-devtools b/bin/wechat-devtools new file mode 100755 index 0000000..99c4797 --- /dev/null +++ b/bin/wechat-devtools @@ -0,0 +1,16 @@ +#!/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" + +exec "$DIR"/../nwjs/nw "$@" --load-extension="$DIR"/../nwjs/package.nw/js/ideplugin "$@" diff --git a/conf/node.json b/conf/node.json new file mode 100644 index 0000000..7d20449 --- /dev/null +++ b/conf/node.json @@ -0,0 +1,4 @@ +{ + "version": "12.6.0", + "url": "https://npm.taobao.org/mirrors/node/v${version}/node-v${version}-linux-x64.tar.gz" +} \ No newline at end of file diff --git a/conf/nwjs.json b/conf/nwjs.json new file mode 100644 index 0000000..5a4455e --- /dev/null +++ b/conf/nwjs.json @@ -0,0 +1,4 @@ +{ + "version": "0.39.3", + "url": "https://npm.taobao.org/mirrors/nwjs/v${version}/nwjs-sdk-v${version}-linux-x64.tar.gz" +} \ No newline at end of file diff --git a/patch/nw-menu.js b/patch/nw-menu.js new file mode 100644 index 0000000..eacbd6a --- /dev/null +++ b/patch/nw-menu.js @@ -0,0 +1,92 @@ +if (typeof nw === "undefined") { + return; +} + +let log = function (content) { + process.stderr.write(content + "\n"); +}; + +let originMenuItem = nw.MenuItem; +nw.MenuItem = function MenuItem(options) { + + options = Object.assign({}, options); + + delete options.shortcutName; + delete options.shouldEnabled; + + if (options.label) { + + if (options.label.indexOf("[") !== -1) { + let rest = options.label.split("[").slice(1).join("[").trim(); + if (rest[rest.length - 1] === "]") { + rest = rest.slice(0, -1).split("+").map((x) => { + if (!x) { return "+" } + switch (x) { + case "↓": { return "Down"; } + case "↑": { return "Up"; } + case "PAGE↓": { return "PageDown"; } + case "PAGE↑": { return "PageUp"; } + case "←": { return "Left"; } + case "→": { return "Right"; } + default: { return x; } + } + }); + if (rest.length > 1) { + options.key = rest[rest.length - 1]; + options.modifiers = rest.slice(0, -1).join("+"); + } else { + options.key = rest[0]; + } + } + options.label = options.label.split("[")[0]; + } + + if (options.label.indexOf("(&") !== -1) { + options.label = options.label.split("(&")[0]; + } + options.label = options.label.replace("&", "").trim(); + + switch (options.label) { + case "Go to Declaration": { options.label = "转到声明"; break; } + case "Go to References": { options.label = "转到引用"; break; } + case "Find All References": { options.label = "查找所有引用"; break; } + case "Find All Implementations": { options.label = "查找所有实现"; break; } + } + + } + + return new originMenuItem(options); + +}; + +let originAppend = nw.Menu.prototype.append; +nw.Menu.prototype.append = function (item) { + + if (item.parentMenu) { + item.parentMenu.remove(item); + } + item.parentMenu = this; + + if ((this.items.length > 0) && + (this.items[this.items.length - 1].type === "separator") && + (item.type === "separator")) { + originInsert.call(this, item, this.items.length); + return; + } + + if ((this.items.length === 0) && (item.type === "separator")) { + originInsert.call(this, item, this.items.length); + return; + } + + return originAppend.call(this, item); +}; + +let originInsert = nw.Menu.prototype.insert; +nw.Menu.prototype.insert = function (item, index) { + if (item.parentMenu) { + item.parentMenu.remove(item); + } + item.parentMenu = this; + return originInsert.call(this, item, index); +}; diff --git a/res/icons/wechat-devtools.png b/res/icons/wechat-devtools.png new file mode 100644 index 0000000..b210139 Binary files /dev/null and b/res/icons/wechat-devtools.png differ diff --git a/res/icons/wechat-devtools.svg b/res/icons/wechat-devtools.svg new file mode 100644 index 0000000..b561436 --- /dev/null +++ b/res/icons/wechat-devtools.svg @@ -0,0 +1,71 @@ + + + + wechat-devtools + Created with Sketch. + + + + + + + + + + + </> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/icons/wechat-devtools128.png b/res/icons/wechat-devtools128.png new file mode 100644 index 0000000..2f1db41 Binary files /dev/null and b/res/icons/wechat-devtools128.png differ diff --git a/res/icons/wechat-devtools256.png b/res/icons/wechat-devtools256.png new file mode 100644 index 0000000..2fe5a7b Binary files /dev/null and b/res/icons/wechat-devtools256.png differ diff --git a/res/icons/wechat-devtools512.png b/res/icons/wechat-devtools512.png new file mode 100644 index 0000000..64715c7 Binary files /dev/null and b/res/icons/wechat-devtools512.png differ diff --git a/res/icons/wechat-devtools64.png b/res/icons/wechat-devtools64.png new file mode 100644 index 0000000..309ceb1 Binary files /dev/null and b/res/icons/wechat-devtools64.png differ diff --git a/res/template.desktop b/res/template.desktop new file mode 100644 index 0000000..c1a5f57 --- /dev/null +++ b/res/template.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Name=WeChat Dev Tools +Name[zh_CN]=微信开发者工具 +Comment=The development tools for wechat projects +Comment[zh_CN]=提供微信开发相关项目的开发IDE支持 +Categories=Development;WebDevelopment;IDE; +Exec=${dir}/bin/wechat-devtools +Icon=wechat-devtools +Type=Application +Terminal=false +StartupWMClass=wechat_devtools +Actions= \ No newline at end of file diff --git a/tools/fix-editor-font b/tools/fix-editor-font new file mode 100755 index 0000000..1052442 --- /dev/null +++ b/tools/fix-editor-font @@ -0,0 +1,14 @@ +#!/usr/bin/env mew_js + +@info("Writing editor configs"); + +const fontFamily = "'Mew Source SC', 'Source Code Pro', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace"; + +let configPath = @.fs.homePath(".config/wechat_devtools/Default/Editor/User/settings.json"); + +let config = JSON.parse(@.fs.readFile.sync(configPath, "utf8")); + +config["editor.fontFamily"] = fontFamily; + +@.fs.makeDirs(@.fs.dirname(configPath)); +@.fs.writeFile.sync(configPath, JSON.stringify(config, null, 4)); diff --git a/tools/fix-package-name b/tools/fix-package-name new file mode 100755 index 0000000..be218e7 --- /dev/null +++ b/tools/fix-package-name @@ -0,0 +1,18 @@ +#!/usr/bin/env mew_js + +const parseFile = function (path) { + + if (!@.fs.exists(path)) { + return; + } + + let content = JSON.parse(@.fs.readFile.sync(path, "utf8")); + + content.name = "wechat_devtools"; + + @.fs.writeFile.sync(path, JSON.stringify(content, null, 4)); + +}; + +parseFile(@path(__dirname, "../package.nw/package.json")); +parseFile(@path(__dirname, "../package.nw/package-lock.json")); diff --git a/tools/install-desktop-icon b/tools/install-desktop-icon new file mode 100755 index 0000000..240a01a --- /dev/null +++ b/tools/install-desktop-icon @@ -0,0 +1,22 @@ +#!/usr/bin/env mew_js + +for (let size of ["64", "128", "256", "512"]) { + let iconPath = @.fs.homePath(`.local/share/icons/hicolor/${size}x${size}/wechat-devtools.png`); + @.fs.makeDirs(@.fs.dirname(iconPath)); + @info(`Writing icon file ${iconPath}`); + @.fs.copyFile.sync(@path(__dirname, "../res/icons", `wechat-devtools${size}.png`), iconPath); +} + +let svgPath = @.fs.homePath(".local/share/icons/hicolor/scalable/wechat-devtools.svg"); +@.fs.makeDirs(@.fs.dirname(svgPath)); +@info(`Writing icon file ${svgPath}`); +@.fs.copyFile.sync(@path(__dirname, "../res/icons/wechat-devtools.svg"), svgPath); + +let desktopCode = @.format(@.fs.readFile.sync(@path(__dirname, "../res/template.desktop"), "utf8"), { + "dir": (@path(__dirname, "..")) + }); + +desktopPath = @.fs.homePath(".local/share/applications/wechat-devtools.desktop"); +@.fs.makeDirs(@.fs.dirname(desktopPath)); +@info(`Writing desktop file ${desktopPath}`); +@.fs.writeFile.sync(desktopPath, desktopCode); diff --git a/tools/patch-wechat-devtools b/tools/patch-wechat-devtools new file mode 100755 index 0000000..f37e7ca --- /dev/null +++ b/tools/patch-wechat-devtools @@ -0,0 +1,32 @@ +#!/usr/bin/env mew_js + +let code = @.fs.readFile.sync(@path(__dirname, "../package.nw/js/unpack/hackrequire/index.js"), "utf8"); + +let signatureBegin = "/* patch wechat devtools begin */\n"; +let signatureEnd = "/* patch wechat devtools end */\n"; + +let index = code.indexOf(signatureBegin); + +let patch = @.fs.listFiles(@path(__dirname, "../patch")).map((file) => { + if ((file.name[0] !== ".") && (@.fs.extname(file.name) === ".js")) { + return (`/* ${file.name} */\n` + + "(() => {\n\n" + + " try {\n\n" + + @.fs.readFile.sync(@path(__dirname, "../patch", file.name), "utf8").trim().split("\n").map((line) => { + return " " + line; + }).join("\n") + "\n\n" + + " } catch (error) {\n" + + " process.stderr.write(error.message);\n" + + " process.stderr.write(error.stack);\n" + + " }\n\n" + + "})();"); + } + return ""; +}).join("\n").trim() + "\n"; + +if (code.indexOf(signatureBegin) !== -1) { + code = code.split(signatureEnd).slice(1).join(signatureEnd); +} + +@.fs.writeFile.sync(@path(__dirname, "../package.nw/js/unpack/hackrequire/index.js"), + signatureBegin + patch + signatureEnd + code); diff --git a/tools/rebuild-node-modules b/tools/rebuild-node-modules new file mode 100755 index 0000000..e6b47a5 --- /dev/null +++ b/tools/rebuild-node-modules @@ -0,0 +1,36 @@ +#!/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 )" + +package_dir="$DIR/../package.nw" + +export PATH=$DIR/../node/bin:$PATH + +rm -fr "${package_dir}/node_modules/vscode-windows-ca-certs" # the module is only available in windows + +rm -fr "${package_dir}/node_modules/vscode-ripgrep/bin" # redownload bin on linux + +rm -fr "${package_dir}/node_modules/nodegit/build" # rebuild nodegit + +(cd "${package_dir}/node_modules" && find -name *.pdb | xargs -I{} rm -r {}) # remove pdb debugging file + +rm -fr "${package_dir}/node_modules_tmp" # remove previous hacking tmp +mkdir -p "${package_dir}/node_modules_tmp" +cp -fr "${package_dir}/node_modules" "${package_dir}/node_modules_tmp/node_modules" + +(cd "${package_dir}/node_modules_tmp" && npm install --registry=https://registry.npm.taobao.org) # prepare package.json and dependencies +(cd "${package_dir}/node_modules_tmp" && npm rebuild --registry=https://registry.npm.taobao.org) # rebuild gyp + +mkdir -p "${package_dir}/node_modules/nodegit/build/Release" +(cd "${package_dir}/node_modules_tmp/node_modules" && find -name *.node | xargs -I{} cp -r {} ${package_dir}/node_modules/{}) + +# mkdir -p "${package_dir}/node_modules/vscode-ripgrep/bin" +cp -fr "${package_dir}/node_modules_tmp/node_modules/vscode-ripgrep/bin" "${package_dir}/node_modules/vscode-ripgrep/bin" + +rm -fr "${package_dir}/node_modules_tmp" diff --git a/tools/setup-wechat-devtools b/tools/setup-wechat-devtools new file mode 100755 index 0000000..6abb3b8 --- /dev/null +++ b/tools/setup-wechat-devtools @@ -0,0 +1,42 @@ +#!/usr/bin/env mew_js + +@.async(function () { + + @info("Initializing node"); + + if (@.fs.exists(@path(__dirname, "../node"))) { + this.next(); return; + } + + @.task.execute(@path(__dirname, "update-node"), [], false, this.test); + +}).then(function () { + + @info("Initializing nwjs"); + + if (@.fs.exists(@path(__dirname, "../nwjs"))) { + this.next(); return; + } + + @.task.execute(@path(__dirname, "update-nwjs"), [], false, this.test); + +}).then(function () { + + @info("Initializing wechat-devtools package"); + + if (@.fs.exists(@path(__dirname, "../package.nw"))) { + this.next(); return; + } + + @.task.execute(@path(__dirname, "update-wechat-devtools"), [], false, this.test); + +}).finished((error) => { + + if (error) { + @error(error); + process.exit(1); + } + + @celebr(`Succeeded setting up wechat-devtools`); + +}); diff --git a/tools/update-node b/tools/update-node new file mode 100755 index 0000000..ff0e6da --- /dev/null +++ b/tools/update-node @@ -0,0 +1,100 @@ +#!/usr/bin/env mew_js + +const node = require("../conf/node.json"); + +@.async(function () { + + @.fs.makeDirs(@path(__dirname, "../cache")); + + let client = @.net.httpClient(); + + let url = @.format(node.url, { "version": node.version }); + + let localPath = @path(__dirname, "../cache", url.split("?")[0].split("/").slice(-1)[0]); + + if (@.fs.exists(localPath)) { + @info(`Cache available ${@.fs.filename(localPath)}`); + this.next(localPath); + return; + } + + let lastSize = 0; + let lastProgress = 0; + let lastTime = Date.now(); + + @info(`Downloading ${url}`); + client.download(url, localPath, { + "resumeBroken": true, + "redirects": Object.create(null), + "onSuccess": () => { + this.next(localPath); + }, + "onProgress": (size, total) => { + let progress = size / total * 100; + let now = Date.now(); + if ((progress - lastProgress > 10) || + (now - lastTime > 1000)) { + let speed = (size - lastSize) / (now - lastTime) * 1000 / 1024; + lastSize = size; + lastTime = now; + lastProgress = progress; + @info(`Downloaded ${@.fs.filename(localPath)}: ${progress.toFixed(2)}%, speed ${speed.toFixed(2)} KiB/s`); + } + }, + "onError": this.reject + }); + +}).then(function (localPath) { + + @info(`Extracting ${localPath}`); + + let extractPath = @path(__dirname, `../tmp/${@.fs.basename(localPath)}`); + + @.fs.deleteFile.sync(extractPath); + + @.fs.makeDirs(extractPath); + + @.task.execute("tar", ["xf", localPath], extractPath, (error) => { + + if (error) { + this.reject(error); return; + } + + this.next(extractPath); + + }); + +}).then(function (extractPath) { + + @info(`Upgrading ${@.fs.filename(extractPath)}`); + + @.fs.deleteFile.sync(@path(__dirname, "../node")); + + @.fs.moveFile.sync(@path(extractPath, @.fs.listFiles(extractPath)[0].name), + @path(__dirname, "../node")) + + @.fs.deleteFile.sync(extractPath); + + if (@.fs.exists(@path(__dirname, "../nwjs"))) { + if (!@.fs.exists(@path(__dirname, "../nwjs/node"))) { + @.fs.linkFile("../node/bin/node", @path(__dirname, "../nwjs/node")); + } + if (!@.fs.exists(@path(__dirname, "../nwjs/node.exe"))) { + @.fs.linkFile("node", @path(__dirname, "../nwjs/node.exe")); + } + } + + this.next(); + +}).finished((error) => { + + if (error) { + @error(error); + process.exit(1); + } + + @celebr(`Succeeded upgrading node to version ${node.version}`); + + process.exit(0); + +}); diff --git a/tools/update-nwjs b/tools/update-nwjs new file mode 100755 index 0000000..a33322b --- /dev/null +++ b/tools/update-nwjs @@ -0,0 +1,99 @@ +#!/usr/bin/env mew_js + +const nwjs = require("../conf/nwjs.json"); + +@.async(function () { + + @.fs.makeDirs(@path(__dirname, "../cache")); + + let client = @.net.httpClient(); + + let url = @.format(nwjs.url, { "version": nwjs.version }); + + let localPath = @path(__dirname, "../cache", url.split("?")[0].split("/").slice(-1)[0]); + + if (@.fs.exists(localPath)) { + @info(`Cache available ${@.fs.filename(localPath)}`); + this.next(localPath); + return; + } + + let lastSize = 0; + let lastProgress = 0; + let lastTime = Date.now(); + + @info(`Downloading ${url}`); + client.download(url, localPath, { + "resumeBroken": true, + "redirects": Object.create(null), + "onSuccess": () => { + this.next(localPath); + }, + "onProgress": (size, total) => { + let progress = size / total * 100; + let now = Date.now(); + if ((progress - lastProgress > 10) || + (now - lastTime > 1000)) { + let speed = (size - lastSize) / (now - lastTime) * 1000 / 1024; + lastSize = size; + lastTime = now; + lastProgress = progress; + @info(`Downloaded ${@.fs.filename(localPath)}: ${progress.toFixed(2)}%, speed ${speed.toFixed(2)} KiB/s`); + } + }, + "onError": this.reject + }); + +}).then(function (localPath) { + + @info(`Extracting ${localPath}`); + + let extractPath = @path(__dirname, `../tmp/${@.fs.basename(localPath)}`); + + @.fs.deleteFile.sync(extractPath); + + @.fs.makeDirs(extractPath); + + @.task.execute("tar", ["xf", localPath], extractPath, (error) => { + + if (error) { + this.reject(error); return; + } + + this.next(extractPath); + + }); + +}).then(function (extractPath) { + + @info(`Upgrading ${@.fs.filename(extractPath)}`); + + @.fs.deleteFile.sync(@path(__dirname, "../nwjs")); + + @.fs.moveFile.sync(@path(extractPath, @.fs.listFiles(extractPath)[0].name), + @path(__dirname, "../nwjs")) + + @.fs.deleteFile.sync(extractPath); + + if (@.fs.exists(@path(__dirname, "../node/bin/node"))) { + @.fs.linkFile("../node/bin/node", @path(__dirname, "../nwjs/node")); + @.fs.linkFile("node", @path(__dirname, "../nwjs/node.exe")); + } + if (!@.fs.exists(@path(__dirname, "../package.nw"))) { + @.fs.linkFile("../package.nw", @path(__dirname, "../nwjs/package.nw")); + } + + this.next(); + +}).finished((error) => { + + if (error) { + @error(error); + process.exit(1); + } + + @celebr(`Succeeded upgrading nwjs to version ${nwjs.version}`); + + process.exit(0); + +}); diff --git a/tools/update-wechat-devtools b/tools/update-wechat-devtools new file mode 100755 index 0000000..f3dc53f --- /dev/null +++ b/tools/update-wechat-devtools @@ -0,0 +1,135 @@ +#!/usr/bin/env mew_js + +const http = require("http"); + +const url = "https://servicewechat.com/wxa-dev-logic/download_redirect?type=x64&from=mpwiki"; + +let version = undefined; + +const packageDir = "$APPDATA/Tencent/微信开发者工具/package.nw"; + +@.async(function () { + + @.fs.makeDirs(@path(__dirname, "../cache")); + + @info(`Downloading ${url}`); + + let localPath = @path(__dirname, "../cache/wechat-devtools-x64.exe"); + + let client = @.net.httpClient(); + + let lastSize = 0; + let lastProgress = 0; + let lastTime = Date.now(); + + let filename = "wechat-devtools-x64.exe"; + + @.fs.deleteFile.sync(localPath); + + client.download(url, localPath, { + "redirects": Object.create(null), + "onSuccess": () => { + let newPath = @path(__dirname, "../cache", filename); + @.fs.moveFile(localPath, newPath); + this.next(newPath); + }, + "onRedirect": (location) => { + @info(`Redirected to ${location}`); + filename = location.split("?")[0].split("/").slice(-1)[0]; + version = filename.split("_").filter((x) => /^[0-9]+\.[0-9]+.[0-9]+$/.test(x))[0]; + let newPath = @path(__dirname, "../cache", filename); + if (@.fs.exists(newPath)) { + this.next(newPath); + return true; + } + }, + "onProgress": (size, total) => { + let progress = size / total * 100; + let now = Date.now(); + if ((progress - lastProgress > 10) || + (now - lastTime > 1000)) { + let speed = (size - lastSize) / (now - lastTime) * 1000 / 1024; + lastSize = size; + lastTime = now; + lastProgress = progress; + @info(`Downloaded ${filename}: ${progress.toFixed(2)}%, speed ${speed.toFixed(2)} KiB/s`); + } + }, + "onError": this.reject + }); + +}).then(function (localPath) { + + @info(`Extracting ${localPath}`); + + let extractPath = @path(__dirname, `../tmp/${@.fs.basename(localPath)}`); + + @.fs.deleteFile.sync(extractPath); + + @.fs.makeDirs(extractPath); + + @.task.execute("7z", ["x", localPath, `-o${extractPath}`, packageDir], extractPath, (error) => { + + if (error) { + this.reject(error); return; + } + + this.next(extractPath); + + }); + +}).then(function (extractPath) { + + @info(`Upgrading ${@.fs.filename(extractPath)}`); + + @.fs.deleteFile.sync(@path(__dirname, "../package.nw")); + + @.fs.moveFile.sync(@path(extractPath, packageDir), + @path(__dirname, "../package.nw")); + + @.fs.deleteFile.sync(extractPath); + + if (@.fs.exists(@path(__dirname, "../nwjs"))) { + if (!@.fs.exists(@path(__dirname, "../nwjs/package.nw"))) { + @.fs.linkFile("../package.nw", @path(__dirname, "../nwjs/package.nw")); + } + } + + this.next(); + +}).then(function () { + + @info("Fixing wechat-devtools package name"); + + @.task.execute(@path(__dirname, "fix-package-name"), [], false, this.test); + +}).then(function () { + + @info("Fix wechat-devtools editor font"); + + @.task.execute(@path(__dirname, "fix-editor-font"), [], false, this.test); + +}).then(function () { + + @info("Rebuilding wechat-devtools node modules"); + + @.task.execute(@path(__dirname, "rebuild-node-modules"), [], false, this.test); + +}).then(function () { + + @info("Patching wechat-devtools"); + + @.task.execute(@path(__dirname, "patch-wechat-devtools"), [], false, this.test); + +}).finished((error) => { + + if (error) { + @error(error); + process.exit(1); + } + + @celebr(`Succeeded upgrading wechat-devtools to version ${version}`); + + process.exit(0); + +}); diff --git a/tools/wechat-devtools-env.sh b/tools/wechat-devtools-env.sh new file mode 100755 index 0000000..1008137 --- /dev/null +++ b/tools/wechat-devtools-env.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +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 )" + +export PATH=$DIR/../node/bin:$PATH +export PATH=$DIR/../nwjs:$PATH