Skip to content

Commit 31be80b

Browse files
xsahxlheimanba
authored andcommitted
fix: execCommand debug not work
Signed-off-by: xsahxl <xsahxl@126.com>
1 parent 431b2e1 commit 31be80b

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/common/execCommand/index.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Parse from './parse';
2-
import { isEmpty, get, isNil, keys, isPlainObject } from 'lodash';
2+
import { isEmpty, get, isNil, keys, isPlainObject, includes, filter } from 'lodash';
33
import { logger, makeLogFile } from '../../logger';
44
import Analysis from './analysis';
55
import { getProjectConfig } from './utils';
@@ -155,7 +155,16 @@ class ExecCommand {
155155
}
156156

157157
async function execCommand(configs: IConfigs) {
158-
return await new ExecCommand(configs).init();
158+
const lastArgv = process.argv;
159+
const debug = get(configs, 'globalArgs.debug');
160+
if (debug) {
161+
!includes(process.argv, '--debug') && process.argv.push('--debug');
162+
} else {
163+
process.argv = filter(process.argv, (item) => item !== '--debug');
164+
}
165+
const res = await new ExecCommand(configs).init();
166+
process.argv = lastArgv;
167+
return res;
159168
}
160169

161170
export { execCommand, getTemplatePath, transforYamlPath, Parse as ParseVariable };

test/fixtures/execCommand.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import { execCommand } from '../../src'
88
env: {
99
// serverless_devs_log_path: '/Users/shihuali/workspace/core/test/fs.log',
1010
// serverless_devs_log_debug: 'false',
11-
default_serverless_devs_auto_log: 'false',
11+
// default_serverless_devs_auto_log: 'false',
1212
},
13-
method: 'deploy'
13+
method: 'deploy',
14+
globalArgs:{
15+
debug: true,
16+
}
1417
})
1518
console.log(data)
1619

0 commit comments

Comments
 (0)