generator-preserve.test-d.ts
This file
Path
test-d/stdio/option/generator-preserve.test-d.ts
49 lines · 2.2 KiB · TypeScript
Last changed by
Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147
History of this fileTake it
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950import {expectTypeOf, expectError} from 'nz';import { execa, execaSync, type StdinOption, type StdinSyncOption, type StdoutStderrOption, type StdoutStderrSyncOption,} from '../../../index.js';
const transformWithPreserveNewlines = { * transform(line: unknown) { yield line; }, preserveNewlines: true,} as const;
await execa('unicorns', {stdin: transformWithPreserveNewlines});execaSync('unicorns', {stdin: transformWithPreserveNewlines});await execa('unicorns', {stdin: [transformWithPreserveNewlines]});execaSync('unicorns', {stdin: [transformWithPreserveNewlines]});
await execa('unicorns', {stdout: transformWithPreserveNewlines});execaSync('unicorns', {stdout: transformWithPreserveNewlines});await execa('unicorns', {stdout: [transformWithPreserveNewlines]});execaSync('unicorns', {stdout: [transformWithPreserveNewlines]});
await execa('unicorns', {stderr: transformWithPreserveNewlines});execaSync('unicorns', {stderr: transformWithPreserveNewlines});await execa('unicorns', {stderr: [transformWithPreserveNewlines]});execaSync('unicorns', {stderr: [transformWithPreserveNewlines]});
expectError(await execa('unicorns', {stdio: transformWithPreserveNewlines}));expectError(execaSync('unicorns', {stdio: transformWithPreserveNewlines}));
await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithPreserveNewlines]});execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithPreserveNewlines]});await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithPreserveNewlines]]});execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithPreserveNewlines]]});
expectTypeOf(transformWithPreserveNewlines).toBeAssignableTo<StdinOption>();expectTypeOf(transformWithPreserveNewlines).toBeAssignableTo<StdinSyncOption>();[transformWithPreserveNewlines] satisfies StdinOption;[transformWithPreserveNewlines] satisfies StdinSyncOption;
expectTypeOf(transformWithPreserveNewlines).toBeAssignableTo<StdoutStderrOption>();expectTypeOf(transformWithPreserveNewlines).toBeAssignableTo<StdoutStderrSyncOption>();[transformWithPreserveNewlines] satisfies StdoutStderrOption;[transformWithPreserveNewlines] satisfies StdoutStderrSyncOption;