Skip to content
Myr

Upgrade `get-stream` (#571)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by GitHub · parent f31fbdb · Browse files · 4 files+50 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+50 added−6 removed

  • tests:+31 added−1 removed
  • other:+19 added−5 removed

4 files+50 added−6 removed

modified:lib/stream.js+18 added-4 removed
added:test/fixtures/noop-no-newline.js+4 added
modified:test/stream.js+27 added-1 removed
1import {Buffer} from 'node:buffer';2import {exec} from 'node:child_process';3import process from 'node:process';4import fs from 'node:fs';5import Stream from 'node:stream';6import {promisify} from 'node:util';7import test from 'ava';8import getStream from 'get-stream';9import {pEvent} from 'p-event';10import tempfile from 'tempfile';11import {execa, execaSync, $} from '../index.js';10import {setFixtureDir} from './helpers/fixtures-dir.js';12import {setFixtureDir, FIXTURES_DIR} from './helpers/fixtures-dir.js';1314setFixtureDir();1516test('buffer', async t => {
1 unmodified line
18 t.true(Buffer.isBuffer(stdout));19 t.is(stdout.toString(), 'foo');20});2122const checkEncoding = async (t, encoding) => {23 const {stdout} = await execa('noop-no-newline.js', [STRING_TO_ENCODE], {encoding});24 t.is(stdout, Buffer.from(STRING_TO_ENCODE).toString(encoding));2526 const {stdout: nativeStdout} = await promisify(exec)(`node noop-no-newline.js ${STRING_TO_ENCODE}`, {encoding, cwd: FIXTURES_DIR});27 t.is(stdout, nativeStdout);28};2930// This string gives different outputs with each encoding type31const STRING_TO_ENCODE = '\u1000.';3233test('can pass encoding "utf8"', checkEncoding, 'utf8');34test('can pass encoding "utf-8"', checkEncoding, 'utf8');35test('can pass encoding "utf16le"', checkEncoding, 'utf16le');36test('can pass encoding "utf-16le"', checkEncoding, 'utf16le');37test('can pass encoding "ucs2"', checkEncoding, 'utf16le');38test('can pass encoding "ucs-2"', checkEncoding, 'utf16le');39test('can pass encoding "latin1"', checkEncoding, 'latin1');40test('can pass encoding "binary"', checkEncoding, 'latin1');41test('can pass encoding "ascii"', checkEncoding, 'ascii');42test('can pass encoding "hex"', checkEncoding, 'hex');43test('can pass encoding "base64"', checkEncoding, 'base64');44test('can pass encoding "base64url"', checkEncoding, 'base64url');4546test('pass `stdout` to a file descriptor', async t => {47 const file = tempfile({extension: '.txt'});48 await execa('noop.js', ['foo bar'], {stdout: fs.openSync(file, 'w')});49 t.is(fs.readFileSync(file, 'utf8'), 'foo bar\n');
233 unmodified lines
modified:package.json+1 added-1 removed
44 unmodified lines
45 "zx"46 ],47 "dependencies": {48 "cross-spawn": "^7.0.3",49 "get-stream": "^6.0.1",49 "get-stream": "^8.0.1",50 "human-signals": "^5.0.0",51 "is-stream": "^3.0.0",52 "merge-stream": "^2.0.0",53 "npm-run-path": "^5.1.0",
37 unmodified lines