command.js
This file
Path
test/command.js
87 lines · 2.9 KiB · JavaScript
Last changed by
Re-enable Windows in CI (#500)ehmickybefore adoption071d0a2
History of this fileTake it
Separate command-related logic into its own file (#329)ehmickybefore adoption46daa7b
line 1why, one step back1import test from 'ava';Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
line 2why, one step back2import {execa, execaSync, execaCommand, execaCommandSync} from '../index.js';Re-enable Windows in CI (#500)ehmickybefore adoption071d0a2
line 3why, one step back3import {setFixtureDir} from './helpers/fixtures-dir.js';Separate command-related logic into its own file (#329)ehmickybefore adoption46daa7b
line 4why, one step back4Re-enable Windows in CI (#500)ehmickybefore adoption071d0a2
line 5why, one step back5setFixtureDir();Separate command-related logic into its own file (#329)ehmickybefore adoption46daa7b
lines 6–7why, one step back67const command = async (t, expected, ...args) => {Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
lines 8–9why, one step back8 const {command: failCommand} = await t.throwsAsync(execa('fail.js', args));9 t.is(failCommand, `fail.js${expected}`);Separate command-related logic into its own file (#329)ehmickybefore adoption46daa7b
line 10why, one step back10Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
lines 11–12why, one step back11 const {command} = await execa('noop.js', args);12 t.is(command, `noop.js${expected}`);Separate command-related logic into its own file (#329)ehmickybefore adoption46daa7b
lines 13–20why, one step back13};1415command.title = (message, expected) => `command is: ${JSON.stringify(expected)}`;1617test(command, ' foo bar', 'foo', 'bar');18test(command, ' baz quz', 'baz', 'quz');19test(command, '');20Add `.escapedCommand` property (#466)ehmickybefore adoption712bafc
line 21why, one step back21const testEscapedCommand = async (t, expected, args) => {Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
lines 22–23why, one step back22 const {escapedCommand: failEscapedCommand} = await t.throwsAsync(execa('fail.js', args));23 t.is(failEscapedCommand, `fail.js ${expected}`);Add `.escapedCommand` property (#466)ehmickybefore adoption712bafc
lines 24–25why, one step back2425 const {escapedCommand: failEscapedCommandSync} = t.throws(() => {Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
line 26why, one step back26 execaSync('fail.js', args);Add `.escapedCommand` property (#466)ehmickybefore adoption712bafc
line 27why, one step back27 });Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
line 28why, one step back28 t.is(failEscapedCommandSync, `fail.js ${expected}`);Add `.escapedCommand` property (#466)ehmickybefore adoption712bafc
line 29why, one step back29Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
lines 30–31why, one step back30 const {escapedCommand} = await execa('noop.js', args);31 t.is(escapedCommand, `noop.js ${expected}`);Add `.escapedCommand` property (#466)ehmickybefore adoption712bafc
line 32why, one step back32Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
lines 33–34why, one step back33 const {escapedCommand: escapedCommandSync} = execaSync('noop.js', args);34 t.is(escapedCommandSync, `noop.js ${expected}`);Add `.escapedCommand` property (#466)ehmickybefore adoption712bafc
lines 35–43why, one step back35};3637testEscapedCommand.title = (message, expected) => `escapedCommand is: ${JSON.stringify(expected)}`;3839test(testEscapedCommand, 'foo bar', ['foo', 'bar']);40test(testEscapedCommand, '"foo bar"', ['foo bar']);41test(testEscapedCommand, '"\\"foo\\""', ['"foo"']);42test(testEscapedCommand, '"*"', ['*']);43Separate command-related logic into its own file (#329)ehmickybefore adoption46daa7b
line 44why, one step back44test('allow commands with spaces and no array arguments', async t => {Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
line 45why, one step back45 const {stdout} = await execa('command with space.js');Separate command-related logic into its own file (#329)ehmickybefore adoption46daa7b
lines 46–49why, one step back46 t.is(stdout, '');47});4849test('allow commands with spaces and array arguments', async t => {Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
line 50why, one step back50 const {stdout} = await execa('command with space.js', ['foo', 'bar']);Separate command-related logic into its own file (#329)ehmickybefore adoption46daa7b
lines 51–53why, one step back51 t.is(stdout, 'foo\nbar');52});53Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
lines 54–55why, one step back54test('execaCommand()', async t => {55 const {stdout} = await execaCommand('node test/fixtures/echo.js foo bar');Separate command-related logic into its own file (#329)ehmickybefore adoption46daa7b
lines 56–58why, one step back56 t.is(stdout, 'foo\nbar');57});58Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
lines 59–60why, one step back59test('execaCommand() ignores consecutive spaces', async t => {60 const {stdout} = await execaCommand('node test/fixtures/echo.js foo bar');Separate command-related logic into its own file (#329)ehmickybefore adoption46daa7b
lines 61–63why, one step back61 t.is(stdout, 'foo\nbar');62});63Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
lines 64–65why, one step back64test('execaCommand() allows escaping spaces in commands', async t => {65 const {stdout} = await execaCommand('command\\ with\\ space.js foo bar');Separate command-related logic into its own file (#329)ehmickybefore adoption46daa7b
lines 66–68why, one step back66 t.is(stdout, 'foo\nbar');67});68Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
lines 69–70why, one step back69test('execaCommand() allows escaping spaces in arguments', async t => {70 const {stdout} = await execaCommand('node test/fixtures/echo.js foo\\ bar');Separate command-related logic into its own file (#329)ehmickybefore adoption46daa7b
lines 71–73why, one step back71 t.is(stdout, 'foo bar');72});73Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
lines 74–75why, one step back74test('execaCommand() escapes other whitespaces', async t => {75 const {stdout} = await execaCommand('node test/fixtures/echo.js foo\tbar');Separate command-related logic into its own file (#329)ehmickybefore adoption46daa7b
lines 76–78why, one step back76 t.is(stdout, 'foo\tbar');77});78Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
lines 79–80why, one step back79test('execaCommand() trims', async t => {80 const {stdout} = await execaCommand(' node test/fixtures/echo.js foo bar ');Separate command-related logic into its own file (#329)ehmickybefore adoption46daa7b
lines 81–83why, one step back81 t.is(stdout, 'foo\nbar');82});83Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
lines 84–85why, one step back84test('execaCommandSync()', t => {85 const {stdout} = execaCommandSync('node test/fixtures/echo.js foo bar');Separate command-related logic into its own file (#329)ehmickybefore adoption46daa7b
lines 86–87why, one step back86 t.is(stdout, 'foo\nbar');87});