InventoryTrack/node_modules/roarr/dist/factories/createNodeWriter.js.flow

23 lines
520 B
Plaintext
Raw Normal View History

2022-11-02 22:16:03 -04:00
// @flow
import type {
WriterType,
} from '../types';
const createBlockingWriter = (stream: stream$Writable): WriterType => {
return {
write: (message: string) => {
stream.write(message + '\n');
},
};
};
export default (): WriterType => {
// eslint-disable-next-line no-process-env
const targetStream = (process.env.ROARR_STREAM || 'STDOUT').toUpperCase();
const stream = targetStream.toUpperCase() === 'STDOUT' ? process.stdout : process.stderr;
return createBlockingWriter(stream);
};