Skip to content

Commit 598a3d8

Browse files
committed
chore: convert tty to TS
1 parent d5797c3 commit 598a3d8

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

packages/server/lib/util/tty.js renamed to packages/server/lib/util/tty.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const tty = require('tty')
2-
const terminalSize = require('./terminal-size')
1+
import tty from 'tty'
2+
import { get as getTerminalSize } from './terminal-size'
33

44
// polyfills node's getWindowSize
55
// by returning an array of columns/rows
6-
function getWindowSize () {
7-
const { columns, rows } = terminalSize.get()
6+
export function getWindowSize () {
7+
const { columns, rows } = getTerminalSize()
88

99
return [columns, rows]
1010
}
@@ -17,7 +17,7 @@ function patchStream (patched, name) {
1717
patched[stream.fd] = true
1818
}
1919

20-
const override = () => {
20+
export function override () {
2121
const isatty = tty.isatty
2222

2323
const patched = {
@@ -54,9 +54,3 @@ const override = () => {
5454

5555
return
5656
}
57-
58-
module.exports = {
59-
override,
60-
61-
getWindowSize,
62-
}

packages/server/start-cypress.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const electronApp = require('./lib/util/electron-app')
22
const { telemetry, OTLPTraceExporterCloud } = require('@packages/telemetry')
33
const { apiRoutes } = require('./lib/cloud/routes')
44
const encryption = require('./lib/cloud/encryption')
5+
const { override: overrideTty } = require('./lib/util/tty')
56

67
const { calculateCypressInternalEnv, configureLongStackTraces } = require('./lib/environment')
78

@@ -64,7 +65,7 @@ const fs = require('fs')
6465
patchFs(fs)
6566

6667
// override tty if we're being forced to
67-
require('./lib/util/tty').override()
68+
overrideTty()
6869

6970
if (process.env.CY_NET_PROFILE && isRunningElectron) {
7071
const netProfiler = require('./lib/util/net_profiler')()

packages/server/test/unit/util/tty_spec.js renamed to packages/server/test/unit/util/tty_spec.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
require('../../spec_helper')
2-
3-
const tty = require('tty')
4-
const ttyUtil = require(`../../../lib/util/tty`)
5-
const terminalSize = require(`../../../lib/util/terminal-size`)
1+
import tty from 'tty'
2+
import * as ttyUtil from '../../../lib/util/tty'
3+
import * as terminalSize from '../../../lib/util/terminal-size'
64

75
const ttys = [process.stdin.isTTY, process.stdout.isTTY, process.stderr.isTTY]
86

0 commit comments

Comments
 (0)