Skip to content

Commit

Permalink
fix: warnings to stderr
Browse files Browse the repository at this point in the history
* fix: warnings to stderr

* test: warnings to stderr

* test: more external NUTs to identify stdout breaks
  • Loading branch information
mshanemc authored Feb 10, 2023
1 parent 2b3445b commit fb0c56a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ jobs:
- plugin-env
- plugin-generate
- plugin-login
- plugin-org
- plugin-data
- plugin-schema
- plugin-limits
- plugin-signups
- plugin-templates
- plugin-custom-metadata
- plugin-community
- plugin-user
os:
- ubuntu-latest
- windows-latest
Expand Down
2 changes: 1 addition & 1 deletion src/sfCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export abstract class SfCommand<T> extends Command {
...this.formatActions(typeof input === 'string' ? [] : input.actions ?? [], { actionColor: StandardColors.info })
);

this.log(colorizedArgs.join(os.EOL));
this.logToStderr(colorizedArgs.join(os.EOL));
return input;
}

Expand Down
14 changes: 7 additions & 7 deletions test/unit/sfCommand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,32 +51,32 @@ describe('info messages', () => {
});
describe('warning messages', () => {
test
.stdout()
.stderr()
.do(() => {
const testCommand = new TestCommand([], {} as Config);
testCommand.warn('foo bar baz');
})
.it('should show a info message from a string', (ctx) => {
expect(ctx.stdout).to.include('Warning: foo bar baz');
expect(ctx.stderr).to.include('Warning: foo bar baz');
});
test
.stdout()
.stderr()
.do(() => {
const testCommand = new TestCommand([], {} as Config);
testCommand.warn(new Error('foo bar baz') as SfCommand.Warning);
})
.it('should show a warning message from Error, no actions', (ctx) => {
expect(ctx.stdout).to.include('Warning: foo bar baz');
expect(ctx.stderr).to.include('Warning: foo bar baz');
});
test
.stdout()
.stderr()
.do(() => {
const testCommand = new TestCommand([], {} as Config);
const infoError = new SfError('foo bar baz', 'foo', ['this', 'is an', 'action']) as Error;
testCommand.warn(infoError as SfCommand.Info);
})
.it('should show a info message from Error, with actions', (ctx) => {
expect(ctx.stdout).to.include('Warning: foo bar baz');
expect(ctx.stdout).to.include(['this', 'is an', 'action'].join(os.EOL));
expect(ctx.stderr).to.include('Warning: foo bar baz');
expect(ctx.stderr).to.include(['this', 'is an', 'action'].join(os.EOL));
});
});

0 comments on commit fb0c56a

Please sign in to comment.