Skip to content

Commit

Permalink
fix: 修复 h-uni-build setMode 命令被覆盖bug,完善命令行提示
Browse files Browse the repository at this point in the history
修复 h-uni-build setMode 命令被覆盖bug,完善命令行提示
  • Loading branch information
hewx815 committed Jun 10, 2023
1 parent cf8f6f9 commit f80bbbf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
Expand Up @@ -18,11 +18,21 @@ module.exports = async (api, options, args) => {
if (setMode && setMode.length !== 0) {
// 选择模式
const names = setMode.map((item) => item.name);

// uni-build 输出后
const bugFix = () => new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, 0);
});

await bugFix();

const { mode } = await inquirer.prompt([
{
type: 'list',
name: 'mode',
message: '请选择启动模式',
message: '[h-uni-build]:请选择启动模式',
choices: names,
},
]);
Expand Down
@@ -1,5 +1,7 @@
/* eslint-disable no-shadow */
/* eslint-disable no-console */
const { spawn } = require('child_process');
const { err, log } = require('../utils');

const projectPath = process.argv[2];
const isExit = process.argv[3];
Expand Down Expand Up @@ -36,20 +38,24 @@ const exit = () => new Promise((resolve, reject) => {

// eslint-disable-next-line no-shadow
const main = async (projectPath) => {
const loginStatus = await isLogin();
if (loginStatus) {
console.log('已登录微信开发者工具');
try {
await openProject(projectPath);
} catch (err) {
console.log('登录已失效,请重新登录');
try {
const loginStatus = await isLogin();
if (loginStatus) {
log('已登录微信开发者工具');
try {
await openProject(projectPath);
} catch (err) {
log('登录已失效,请重新登录');
await login();
}
} else {
log('未登录微信开发者工具');
await login();
log('请使用微信扫描二维码登录');
await openProject(projectPath);
}
} else {
console.log('未登录微信开发者工具');
await login();
console.log('请使用微信扫描二维码登录');
await openProject(projectPath);
} catch (e) {
err(e);
}
};

Expand Down
Expand Up @@ -10,7 +10,7 @@ const err = (message) => {
const log = (message) => {
// eslint-disable-next-line no-console
console.log(`
[h-uni-builds]:${message}
[h-uni-build]:${message}
`);
};

Expand Down

0 comments on commit f80bbbf

Please sign in to comment.