From 181b03273c4c9282d8176953d68713e37b50294b Mon Sep 17 00:00:00 2001 From: Dmitry Sharshakov Date: Sun, 3 Feb 2019 06:05:30 +0300 Subject: Add isTTY function (#1622) --- tools/is_tty_test.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 tools/is_tty_test.py (limited to 'tools/is_tty_test.py') diff --git a/tools/is_tty_test.py b/tools/is_tty_test.py new file mode 100755 index 000000000..218e7f620 --- /dev/null +++ b/tools/is_tty_test.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +import os +import pty +import select +import subprocess +from util import build_path, executable_suffix +from sys import stdin +from permission_prompt_test import tty_capture + +IS_TTY_TEST_TS = "tests/is_tty.ts" + +def is_tty_test(deno_exe): + cmd = [deno_exe, IS_TTY_TEST_TS] + code, stdout, _ = tty_capture(cmd, b'') + assert code == 0 + assert str(stdin.isatty()).lower() in stdout + +def main(): + deno_exe = os.path.join(build_path(), "deno" + executable_suffix) + is_tty_test(deno_exe) + +if __name__ == "__main__": + main() -- cgit v1.2.3