diff --git a/src/flags.ts b/src/flags.ts index bab81144..79fe64ad 100644 --- a/src/flags.ts +++ b/src/flags.ts @@ -20,12 +20,11 @@ export function preprocessCliFlags(process: ProcessLike): void { process.argv.map((arg) => { if (arg === '--dev-debug') { let debug = '*'; - const filterIndex = process.argv.indexOf('--dev-filter'); + const filterIndex = process.argv.indexOf('--debug-filter'); if (filterIndex > 0) { debug = process.argv[filterIndex + 1]; - process.argv.splice(filterIndex + 1, 1); - process.argv.splice(filterIndex, 1); + process.argv.splice(filterIndex, 2); } // convert --dev-debug into a set of environment variables process.env.DEBUG = debug; @@ -34,7 +33,7 @@ export function preprocessCliFlags(process: ProcessLike): void { process.env.SFDX_DEBUG = '1'; process.env.SFDX_ENV = 'development'; - // need to calculate indexOf --dev-debug here because it might've changed based on --dev-filter + // need to calculate indexOf --dev-debug here because it might've changed based on --debug-filter process.argv.splice(process.argv.indexOf('--dev-debug'), 1); } }); diff --git a/test/flags.test.ts b/test/flags.test.ts index cd97d618..d9f61c12 100644 --- a/test/flags.test.ts +++ b/test/flags.test.ts @@ -49,7 +49,7 @@ describe('CLI flags', () => { it('should recognize --dev-debug with a DEBUG filter', () => { const process: ProcessLike = { - argv: ['--dev-debug', '--dev-filter', 'sf:config'], + argv: ['--dev-debug', '--debug-filter', 'sf:config'], env: {}, }; preprocessCliFlags(process); @@ -64,7 +64,7 @@ describe('CLI flags', () => { it('should recognize --dev-debug with a DEBUG filter in any order', () => { const process: ProcessLike = { - argv: ['--setdefault', '--dev-filter', 'sf:Config', '--dev-debug'], + argv: ['--setdefault', '--debug-filter', 'sf:Config', '--dev-debug'], env: {}, }; preprocessCliFlags(process); @@ -80,11 +80,11 @@ describe('CLI flags', () => { it('should only set DEBUG if --dev-debug is present', () => { const process: ProcessLike = { - argv: ['--setdefault', '--dev-filter', 'sf:Config'], + argv: ['--setdefault', '--debug-filter', 'sf:Config'], env: {}, }; preprocessCliFlags(process); - expect(process.argv).to.deep.equal(['--setdefault', '--dev-filter', 'sf:Config']); + expect(process.argv).to.deep.equal(['--setdefault', '--debug-filter', 'sf:Config']); expect(process.env.DEBUG).to.undefined; expect(process.env.SF_DEBUG).to.be.undefined; expect(process.env.SF_ENV).to.undefined;