Skip to content

Commit 3bd9c09

Browse files
committed
:fix: fixed some bugs
1 parent 03585af commit 3bd9c09

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/commands/git/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const path = require('path');
4-
const { fs, _, chalk, execa, Env } = require('@micro-app/shared-utils');
4+
const { fs, _, chalk, Env } = require('@micro-app/shared-utils');
55
const CONSTANTS = require('../../constants');
66
const { execGit, execGitSync, getCurrBranch, getGitBranch, getGitUser } = require('./utils');
77

src/commands/git/utils.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const { _, execa } = require('@micro-app/shared-utils');
3+
const { logger, execa } = require('@micro-app/shared-utils');
44

55
const TIMEOUT = 1000 * 60 * 3;
66

@@ -24,8 +24,13 @@ function execGit(args, options = {}) {
2424
}
2525

2626
function execGitSync(args, options = {}) {
27-
const { stdout, exitCode } = execa.sync('git', args, Object.assign({ stdio: 'ignore', timeout: TIMEOUT }, options));
28-
return exitCode === 0 ? (stdout || '').trim() : '';
27+
try {
28+
const { stdout, exitCode } = execa.sync('git', args, Object.assign({ stdio: 'ignore', timeout: TIMEOUT }, options));
29+
return exitCode === 0 ? (stdout || '').trim() : '';
30+
} catch (error) {
31+
logger.warn('execGitSync', error);
32+
return '';
33+
}
2934
}
3035

3136
function getCurrBranch() {
@@ -49,11 +54,11 @@ function getGitBranch(deployConfig) {
4954

5055
function getGitUser(deployConfig) {
5156
let userName = deployConfig.userName;
52-
if (_.isEmpty(userName)) {
57+
if (!userName) {
5358
userName = execGitSync([ 'config', 'user.name' ]);
5459
}
5560
let userEmail = deployConfig.userEmail;
56-
if (_.isEmpty(userEmail)) {
61+
if (!userEmail) {
5762
userEmail = execGitSync([ 'config', 'user.email' ]);
5863
}
5964
return {

0 commit comments

Comments
 (0)