strfry-policies/src/stdin.ts

15 lines
348 B
TypeScript
Raw Normal View History

2023-03-24 19:36:11 +00:00
import { readLines } from './deps.ts';
import type { InputMessage } from './types.ts';
/**
* Get the first line from stdin.
* Can only be read ONCE, or else it returns undefined.
*/
async function readStdin(): Promise<InputMessage> {
const { value } = await readLines(Deno.stdin).next();
return JSON.parse(value);
}
export { readStdin };