()
| 37 | } |
| 38 | |
| 39 | export function readDataFromStdin(): Promise<string> { |
| 40 | return new Promise((resolve, reject) => { |
| 41 | try { |
| 42 | const stdin = process.stdin |
| 43 | const inputChunks: string[] = [] |
| 44 | stdin.resume() |
| 45 | stdin.on('data', chunk => { |
| 46 | inputChunks.push(chunk.toString()) |
| 47 | }) |
| 48 | stdin.on('end', () => { |
| 49 | resolve(inputChunks.join('')) |
| 50 | }) |
| 51 | } catch (error) { |
| 52 | reject(error) |
| 53 | } |
| 54 | }) |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Simple function to test for TTY input. Use this instead of directly calling `process` if you want |
no outgoing calls
no test coverage detected