redirect-output
Version:
Provides a way to redirect the output stream to a file
88 lines (58 loc) • 1.42 kB
Markdown
//img.shields.io/npm/v/envisor.svg)](https://www.npmjs.org/package/redirect-output)
[](https://travis-ci.org/monolithed/redirect-output)
[](LICENSE.txt)
> Provides a way to redirect the output stream (stdout/stderr) to a file.
## Installation:
```shell
npm install redirect-output
```
## Usage
*For example you could use the following code:*
```ts
import * as path from 'path';
import RedirectOutput from 'redirect-output';
let output = new RedirectOutput();
let file = path.join(__dirname, 'console.log');
output.write(file);
// Write some text to file and stdout/stderr
console.log('text');
// Restoring original output
output.reset();
// Write some text to stdout only
console.log('text');
```
See fs.WriteStream
```ts
interface IOptions {
flags?: string;
encoding?: string;
fd?: number;
mode?: number;
autoClose?: boolean;
start?: number;
[ ]: any;
}
```
Redirect the output stream to a file.
Restore original streams.
```
npm test
```
```
DEBUG=redirect-output npm test
```
```
npm test
npm publish
```
MIT
[![npm version badge](https: