Skip to content
Myr

nested-sync-tty.js

This file

Path

test/fixtures/nested-sync-tty.js

26 lines · 675 bytes · JavaScript

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than 9f65b86 point at it.

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 1–26why, one step back
1#!/usr/bin/env node
2import process from 'node:process';3import tty from 'node:tty';4import {execa, execaSync} from '../../index.js';56const mockIsatty = fdNumber => {7 tty.isatty = fdNumberArgument => fdNumber === fdNumberArgument;8};910const originalIsatty = tty.isatty;11const unmockIsatty = () => {12 tty.isatty = originalIsatty;13};1415const [options, isSync, file, fdNumber, ...commandArguments] = process.argv.slice(2);16mockIsatty(Number(fdNumber));1718try {19 if (isSync === 'true') {20 execaSync(file, [fdNumber, ...commandArguments], JSON.parse(options));21 } else {22 await execa(file, [fdNumber, ...commandArguments], JSON.parse(options));23 }24} finally {25 unmockIsatty();26}