"use strict";
// Lifted from: https://github.com/oclif/oclif/issues/245#issuecomment-604413364
// in 
// https://github.com/hackmdio/hackmd-cli
// 
// https://github.com/hackmdio/hackmd-cli/blob/f4779995ad2a05aab676bcefa471df8886710624/src/read-stdin-stream.ts
// https://github.com/hackmdio/hackmd-cli/blob/f4779995ad2a05aab676bcefa471df8886710624/src/index.ts#L18-L20
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const readStdin = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
    return new Promise(resolveStdin => {
        // const stdin = process.openStdin();  obsoleted from node
        process.stdin.resume(); // bc stdin is paused by default
        const stdin = process.stdin;
        stdin.setEncoding('utf-8');
        let data;
        stdin.on('data', chunk => {
            if (data == undefined)
                data = '';
            data += chunk;
        });
        stdin.on('end', () => {
            resolveStdin(data);
        });
        stdin.on('error', (err) => {
            resolveStdin(undefined);
        });
        if (stdin.isTTY) {
            resolveStdin(undefined);
        }
    });
});
exports.default = readStdin;
//# sourceMappingURL=read-stdin.js.map