Skip to content

Commit

Permalink
chore: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Dec 13, 2022
1 parent eb2cd39 commit 9d671b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
});
Expand Down
8 changes: 4 additions & 4 deletions test/flags.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 9d671b8

Please sign in to comment.