command.js
This file
Path
test/command.js
112 lines · 3.9 KiB · JavaScript
Last changed by
Allow template strings with all methods (#933)ehmickybefore adoption8074d85
History of this fileTake it
The walk stopped after 200 commits: lines older than bea94d6 point at it.
Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 1why, one step back1import {join} from 'node:path';Add race condition-related tests (#618)ehmickybefore adoptionbea94d6
line 2why, one step back2import test from 'ava';Split files (#791)ehmickybefore adoption932fb26
line 3why, one step back3import {execaCommand, execaCommandSync} from '../index.js';Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 4–5why, one step back4import {setFixtureDir, FIXTURES_DIR} from './helpers/fixtures-dir.js';5import {QUOTE} from './helpers/verbose.js';Add race condition-related tests (#618)ehmickybefore adoptionbea94d6
lines 6–7why, one step back67setFixtureDir();Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 8why, one step back8const STDIN_FIXTURE = join(FIXTURES_DIR, 'stdin.js');Add race condition-related tests (#618)ehmickybefore adoptionbea94d6
lines 9–14why, one step back910test('execaCommand()', async t => {11 const {stdout} = await execaCommand('echo.js foo bar');12 t.is(stdout, 'foo\nbar');13});14Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 15–69why, one step back15test('execaCommandSync()', t => {16 const {stdout} = execaCommandSync('echo.js foo bar');17 t.is(stdout, 'foo\nbar');18});1920test('execaCommand`...`', async t => {21 const {stdout} = await execaCommand`${'echo.js foo bar'}`;22 t.is(stdout, 'foo\nbar');23});2425test('execaCommandSync`...`', t => {26 const {stdout} = execaCommandSync`${'echo.js foo bar'}`;27 t.is(stdout, 'foo\nbar');28});2930test('execaCommand(options)`...`', async t => {31 const {stdout} = await execaCommand({stripFinalNewline: false})`${'echo.js foo bar'}`;32 t.is(stdout, 'foo\nbar\n');33});3435test('execaCommandSync(options)`...`', t => {36 const {stdout} = execaCommandSync({stripFinalNewline: false})`${'echo.js foo bar'}`;37 t.is(stdout, 'foo\nbar\n');38});3940test('execaCommand(options)()', async t => {41 const {stdout} = await execaCommand({stripFinalNewline: false})('echo.js foo bar');42 t.is(stdout, 'foo\nbar\n');43});4445test('execaCommandSync(options)()', t => {46 const {stdout} = execaCommandSync({stripFinalNewline: false})('echo.js foo bar');47 t.is(stdout, 'foo\nbar\n');48});4950test('execaCommand().pipe(execaCommand())', async t => {51 const {stdout} = await execaCommand('echo.js foo bar').pipe(execaCommand(`node ${STDIN_FIXTURE}`));52 t.is(stdout, 'foo\nbar');53});5455test('execaCommand().pipe(...) does not use execaCommand', async t => {56 const {escapedCommand} = await execaCommand('echo.js foo bar').pipe(`node ${STDIN_FIXTURE}`, {reject: false});57 t.true(escapedCommand.startsWith(`${QUOTE}node `));58});5960test('execaCommand() bound options have lower priority', async t => {61 const {stdout} = await execaCommand({stripFinalNewline: false})('echo.js foo bar', {stripFinalNewline: true});62 t.is(stdout, 'foo\nbar');63});6465test('execaCommandSync() bound options have lower priority', t => {66 const {stdout} = execaCommandSync({stripFinalNewline: false})('echo.js foo bar', {stripFinalNewline: true});67 t.is(stdout, 'foo\nbar');68});69Add race condition-related tests (#618)ehmickybefore adoptionbea94d6
lines 70–94why, one step back70test('execaCommand() ignores consecutive spaces', async t => {71 const {stdout} = await execaCommand('echo.js foo bar');72 t.is(stdout, 'foo\nbar');73});7475test('execaCommand() allows escaping spaces in commands', async t => {76 const {stdout} = await execaCommand('command\\ with\\ space.js foo bar');77 t.is(stdout, 'foo\nbar');78});7980test('execaCommand() allows escaping spaces in arguments', async t => {81 const {stdout} = await execaCommand('echo.js foo\\ bar');82 t.is(stdout, 'foo bar');83});8485test('execaCommand() escapes other whitespaces', async t => {86 const {stdout} = await execaCommand('echo.js foo\tbar');87 t.is(stdout, 'foo\tbar');88});8990test('execaCommand() trims', async t => {91 const {stdout} = await execaCommand(' echo.js foo bar ');92 t.is(stdout, 'foo\nbar');93});94Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 95why, one step back95const testInvalidArgsArray = (t, execaMethod) => {Improve input validation (#838)ehmickybefore adoption8ee137c
line 96why, one step back96 t.throws(() => {Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 97–98why, one step back97 execaMethod('echo', ['foo']);98 }, {message: /The command and its arguments must be passed as a single string/});Improve input validation (#838)ehmickybefore adoption8ee137c
lines 99–100why, one step back99};100Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 101–102why, one step back101test('execaCommand() must not pass an array of arguments', testInvalidArgsArray, execaCommand);102test('execaCommandSync() must not pass an array of arguments', testInvalidArgsArray, execaCommandSync);Improve input validation (#838)ehmickybefore adoption8ee137c
line 103why, one step back103Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 104why, one step back104const testInvalidArgsTemplate = (t, execaMethod) => {Improve input validation (#838)ehmickybefore adoption8ee137c
line 105why, one step back105 t.throws(() => {Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 106–107why, one step back106 // eslint-disable-next-line no-unused-expressions107 execaMethod`echo foo`;Improve error message when passing wrong arguments to `execaCommand()` (#899)ehmickybefore adoptiond1889f6
line 108why, one step back108 }, {message: /The command and its arguments must be passed as a single string/});Improve input validation (#838)ehmickybefore adoption8ee137c
lines 109–110why, one step back109};110Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 111–112why, one step back111test('execaCommand() must not pass an array of arguments with a template string', testInvalidArgsTemplate, execaCommand);112test('execaCommandSync() must not pass an array of arguments with a template string', testInvalidArgsTemplate, execaCommandSync);