file-path-mixed.js
This file
Path
test/stdio/file-path-mixed.js
95 lines · 6.2 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
The walk stopped after 200 commits: lines older than 9f65b86 point at it.
TweaksSindre Sorhusbefore adoption698a1b8
line 1why, one step back1import assert from 'node:assert/strict';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 2–3why, one step back2import {readFile, writeFile, rm} from 'node:fs/promises';3import {pathToFileURL} from 'node:url';TweaksSindre Sorhusbefore adoption698a1b8
line 4why, one step back4import test from 'node:test';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 5–14why, one step back5import tempfile from 'tempfile';6import {execa, execaSync} from '../../index.js';7import {setFixtureDirectory} from '../helpers/fixtures-directory.js';8import {getStdio} from '../helpers/stdio.js';9import {foobarString, foobarUppercase} from '../helpers/input.js';10import {uppercaseGenerator} from '../helpers/generator.js';11import {getAbsolutePath} from '../helpers/file-path.js';1213setFixtureDirectory();14TweaksSindre Sorhusbefore adoption698a1b8
line 15why, one step back15const testInputFileTransform = async (fdNumber, mapFile, execaMethod) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 16–22why, one step back16 const filePath = tempfile();17 await writeFile(filePath, foobarString);18 const {stdout} = await execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [19 new Uint8Array(),20 mapFile(filePath),21 uppercaseGenerator(),22 ]));TweaksSindre Sorhusbefore adoption698a1b8
line 23why, one step back23 assert.equal(stdout, foobarUppercase);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 24–26why, one step back24 await rm(filePath);25};26TweaksSindre Sorhusbefore adoption698a1b8
lines 27–32why, one step back27test('stdin can use generators together with input file paths', () => testInputFileTransform(0, getAbsolutePath, execa));28test('stdin can use generators together with input file URLs', () => testInputFileTransform(0, pathToFileURL, execa));29test('stdio[*] can use generators together with input file paths', () => testInputFileTransform(3, getAbsolutePath, execa));30test('stdio[*] can use generators together with input file URLs', () => testInputFileTransform(3, pathToFileURL, execa));31test('stdin can use generators together with input file paths, sync', () => testInputFileTransform(0, getAbsolutePath, execaSync));32test('stdin can use generators together with input file URLs, sync', () => testInputFileTransform(0, pathToFileURL, execaSync));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 33why, one step back33TweaksSindre Sorhusbefore adoption698a1b8
line 34why, one step back34const testOutputFileTransform = async (fdNumber, mapFile, execaMethod) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 35–39why, one step back35 const filePath = tempfile();36 await execaMethod('noop-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, [37 uppercaseGenerator(),38 mapFile(filePath),39 ]));TweaksSindre Sorhusbefore adoption698a1b8
line 40why, one step back40 assert.equal(await readFile(filePath, 'utf8'), `${foobarUppercase}\n`);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 41–43why, one step back41 await rm(filePath);42};43TweaksSindre Sorhusbefore adoption698a1b8
lines 44–55why, one step back44test('stdout can use generators together with output file paths', () => testOutputFileTransform(1, getAbsolutePath, execa));45test('stdout can use generators together with output file URLs', () => testOutputFileTransform(1, pathToFileURL, execa));46test('stderr can use generators together with output file paths', () => testOutputFileTransform(2, getAbsolutePath, execa));47test('stderr can use generators together with output file URLs', () => testOutputFileTransform(2, pathToFileURL, execa));48test('stdio[*] can use generators together with output file paths', () => testOutputFileTransform(3, getAbsolutePath, execa));49test('stdio[*] can use generators together with output file URLs', () => testOutputFileTransform(3, pathToFileURL, execa));50test('stdout can use generators together with output file paths, sync', () => testOutputFileTransform(1, getAbsolutePath, execaSync));51test('stdout can use generators together with output file URLs, sync', () => testOutputFileTransform(1, pathToFileURL, execaSync));52test('stderr can use generators together with output file paths, sync', () => testOutputFileTransform(2, getAbsolutePath, execaSync));53test('stderr can use generators together with output file URLs, sync', () => testOutputFileTransform(2, pathToFileURL, execaSync));54test('stdio[*] can use generators together with output file paths, sync', () => testOutputFileTransform(3, getAbsolutePath, execaSync));55test('stdio[*] can use generators together with output file URLs, sync', () => testOutputFileTransform(3, pathToFileURL, execaSync));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 56why, one step back56TweaksSindre Sorhusbefore adoption698a1b8
line 57why, one step back57const testOutputFileLines = async (fdNumber, mapFile, execaMethod) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 58–62why, one step back58 const filePath = tempfile();59 const {stdio} = await execaMethod('noop-fd.js', [`${fdNumber}`, foobarString], {60 ...getStdio(fdNumber, mapFile(filePath)),61 lines: true,62 });TweaksSindre Sorhusbefore adoption698a1b8
lines 63–64why, one step back63 assert.deepEqual(stdio[fdNumber], [foobarString]);64 assert.equal(await readFile(filePath, 'utf8'), foobarString);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 65–67why, one step back65 await rm(filePath);66};67TweaksSindre Sorhusbefore adoption698a1b8
lines 68–79why, one step back68test('stdout can use "lines: true" together with output file paths', () => testOutputFileLines(1, getAbsolutePath, execa));69test('stdout can use "lines: true" together with output file URLs', () => testOutputFileLines(1, pathToFileURL, execa));70test('stderr can use "lines: true" together with output file paths', () => testOutputFileLines(2, getAbsolutePath, execa));71test('stderr can use "lines: true" together with output file URLs', () => testOutputFileLines(2, pathToFileURL, execa));72test('stdio[*] can use "lines: true" together with output file paths', () => testOutputFileLines(3, getAbsolutePath, execa));73test('stdio[*] can use "lines: true" together with output file URLs', () => testOutputFileLines(3, pathToFileURL, execa));74test('stdout can use "lines: true" together with output file paths, sync', () => testOutputFileLines(1, getAbsolutePath, execaSync));75test('stdout can use "lines: true" together with output file URLs, sync', () => testOutputFileLines(1, pathToFileURL, execaSync));76test('stderr can use "lines: true" together with output file paths, sync', () => testOutputFileLines(2, getAbsolutePath, execaSync));77test('stderr can use "lines: true" together with output file URLs, sync', () => testOutputFileLines(2, pathToFileURL, execaSync));78test('stdio[*] can use "lines: true" together with output file paths, sync', () => testOutputFileLines(3, getAbsolutePath, execaSync));79test('stdio[*] can use "lines: true" together with output file URLs, sync', () => testOutputFileLines(3, pathToFileURL, execaSync));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 80why, one step back80TweaksSindre Sorhusbefore adoption698a1b8
line 81why, one step back81const testOutputFileNoBuffer = async (buffer, execaMethod) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 82–86why, one step back82 const filePath = tempfile();83 const {stdout} = await execaMethod('noop-fd.js', ['1', foobarString], {84 stdout: getAbsolutePath(filePath),85 buffer,86 });TweaksSindre Sorhusbefore adoption698a1b8
lines 87–88why, one step back87 assert.equal(stdout, undefined);88 assert.equal(await readFile(filePath, 'utf8'), foobarString);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 89–91why, one step back89 await rm(filePath);90};91TweaksSindre Sorhusbefore adoption698a1b8
lines 92–95why, one step back92test('stdout can use "buffer: false" together with output file paths', () => testOutputFileNoBuffer(false, execa));93test('stdout can use "buffer: false" together with output file paths, fd-specific', () => testOutputFileNoBuffer({stdout: false}, execa));94test('stdout can use "buffer: false" together with output file paths, sync', () => testOutputFileNoBuffer(false, execaSync));95test('stdout can use "buffer: false" together with output file paths, fd-specific, sync', () => testOutputFileNoBuffer({stdout: false}, execaSync));