-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #832 from oclif/mdonnalley/no-wrapped-process
feat: no longer use wrapped process.stdout and process.stderr
- Loading branch information
Showing
24 changed files
with
175 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import type {SinonSandbox, SinonStub} from 'sinon' | ||
|
||
import write from './write' | ||
|
||
type Stubs = { | ||
stderr: SinonStub | ||
stdout: SinonStub | ||
} | ||
|
||
/** | ||
* Create sinon stubs for writing to stdout and stderr. | ||
* | ||
* @example | ||
* import {ux} from '@oclif/core' | ||
* | ||
* describe('example', () => { | ||
* let sandbox: SinonSandbox | ||
* let stubs: ReturnType<typeof ux.makeStubs> | ||
* | ||
* beforeEach(() => { | ||
* sandbox = createSandbox() | ||
* stubs = ux.makeStubs(sandbox) | ||
* }) | ||
* | ||
* afterEach(() => { | ||
* sandbox.restore() | ||
* }) | ||
* | ||
* it('should log text to the console', () => { | ||
* ux.log('Hello, world!') | ||
* expect(stubs.stdout.firstCall.firstArg).to.equal('Hello, world!\n') | ||
* }) | ||
* }) | ||
*/ | ||
export function makeStubs(sandbox: SinonSandbox): Stubs { | ||
return { | ||
stderr: sandbox.stub(write, 'stderr'), | ||
stdout: sandbox.stub(write, 'stdout'), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const stdout = (msg: string): void => { | ||
process.stdout.write(msg) | ||
} | ||
|
||
const stderr = (msg: string): void => { | ||
process.stderr.write(msg) | ||
} | ||
|
||
export default { | ||
stderr, | ||
stdout, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.