Skip to content

Commit

Permalink
fix(e2e): 修复mac开发者路径问题,只有windows才主动查找开发者工具路径
Browse files Browse the repository at this point in the history
re #80
  • Loading branch information
fanniehuang committed Aug 10, 2021
1 parent c04f321 commit 0f4489f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/wxa-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webank/wxa-cli2-apple",
"version": "1.1.6-test-v28",
"version": "1.1.6-test-v35",
"description": "cli for wxa development",
"main": "dist/wxa.js",
"scripts": {
Expand Down
13 changes: 8 additions & 5 deletions packages/wxa-cli/src/tester/wxa-e2eTest/findWechatPath.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
/*
Windows 环境下去主动查找微信开发者工具安装目录
uct8086 2021-07-08
*/
const fs = require('fs');
const os = require('os');
const os = require('os');
const sys_readfile = require('util').promisify(fs.readFile);
const path = require('path');
const CONFIG_PATH = '微信web开发者工具';
Expand All @@ -14,7 +14,10 @@ class FindWechatPath {
static async start() {
// 只查Windows平台
const platform = os.platform();
if (!platform.includes('win')) return console.log('Non-Windows system, skip');
if (platform !== 'win32') {
console.log('Non-Windows system, skip');
return;
}
// 有缓存文件就直接读取
const exists = await fs.existsSync(`${__dirname}/wechat.cfg`);
if (exists) return await sys_readfile(`${__dirname}/wechat.cfg`, 'utf-8');
Expand All @@ -27,7 +30,7 @@ class FindWechatPath {
let isDir = await this.checkFile(currentPath);
if (isDir) {
tempPath = currentPath;
break label;
break label;
}
}
}
Expand Down Expand Up @@ -55,7 +58,7 @@ class FindWechatPath {
if (deep >= 4) { // 最深不超过4层
console.log(dirName);
return 'begin';
}
}
let filePath = path.resolve(`${dirName}`);
return new Promise((resolve) => {
fs.readdir(filePath, async (err, files) => {
Expand Down
5 changes: 3 additions & 2 deletions packages/wxa-cli/src/tester/wxa-e2eTest/runWechatTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ export default async function(cmd, wxaConfigs) {
};
let {cliPath} = cmd;
let wechatwebdevtools = wxaConfigs.wechatwebdevtools;
if (!wechatwebdevtools || wechatwebdevtools === '/Applications/wechatwebdevtools.app') {
console.log('find wechatWebDevTools......');
// window才查路径
if (process.platform === 'win32' && (!wechatwebdevtools || wechatwebdevtools === '/Applications/wechatwebdevtools.app')) {
console.log('find wechatWebDevTools......', os.platform());
wechatwebdevtools = await FindWechatPath.start();
console.log('wechatwebdevtools: ', wechatwebdevtools);
}
Expand Down

0 comments on commit 0f4489f

Please sign in to comment.