parameters-command.js
This file
Path
test/methods/parameters-command.js
87 lines · 5.1 KiB · JavaScript
Last changed by
Upgrade xo (#980)ehmickybefore adoptionccfa412
History of this fileTake it
Rename files (#977)ehmickybefore adoption4b2e316
lines 1–3why, one step back1import {join, basename} from 'node:path';2import {fileURLToPath} from 'node:url';3import test from 'ava';Upgrade xo (#980)ehmickybefore adoptionccfa412
lines 4–12why, one step back4import {5 execa,6 execaSync,7 execaCommand,8 execaCommandSync,9 execaNode,10 $,11} from '../../index.js';12import {setFixtureDirectory, FIXTURES_DIRECTORY_URL} from '../helpers/fixtures-directory.js';Rename files (#977)ehmickybefore adoption4b2e316
lines 13–14why, one step back13import {foobarString} from '../helpers/input.js';14Upgrade xo (#980)ehmickybefore adoptionccfa412
line 15why, one step back15setFixtureDirectory();Rename files (#977)ehmickybefore adoption4b2e316
lines 16–17why, one step back1617const testFileUrl = async (t, execaMethod) => {Upgrade xo (#980)ehmickybefore adoptionccfa412
line 18why, one step back18 const command = new URL('noop.js', FIXTURES_DIRECTORY_URL);Rename files (#977)ehmickybefore adoption4b2e316
lines 19–45why, one step back19 const {stdout} = await execaMethod(command);20 t.is(stdout, foobarString);21};2223test('execa()\'s command argument can be a file URL', testFileUrl, execa);24test('execaSync()\'s command argument can be a file URL', testFileUrl, execaSync);25test('execaCommand()\'s command argument can be a file URL', testFileUrl, execaCommand);26test('execaCommandSync()\'s command argument can be a file URL', testFileUrl, execaCommandSync);27test('execaNode()\'s command argument can be a file URL', testFileUrl, execaNode);28test('$\'s command argument can be a file URL', testFileUrl, $);29test('$.sync\'s command argument can be a file URL', testFileUrl, $.sync);3031const testInvalidFileUrl = async (t, execaMethod) => {32 const invalidUrl = new URL('https://invalid.com');33 t.throws(() => {34 execaMethod(invalidUrl);35 }, {code: 'ERR_INVALID_URL_SCHEME'});36};3738test('execa()\'s command argument cannot be a non-file URL', testInvalidFileUrl, execa);39test('execaSync()\'s command argument cannot be a non-file URL', testInvalidFileUrl, execaSync);40test('execaCommand()\'s command argument cannot be a non-file URL', testInvalidFileUrl, execaCommand);41test('execaCommandSync()\'s command argument cannot be a non-file URL', testInvalidFileUrl, execaCommandSync);42test('execaNode()\'s command argument cannot be a non-file URL', testInvalidFileUrl, execaNode);43test('$\'s command argument cannot be a non-file URL', testInvalidFileUrl, $);44test('$.sync\'s command argument cannot be a non-file URL', testInvalidFileUrl, $.sync);45Upgrade xo (#980)ehmickybefore adoptionccfa412
line 46why, one step back46const testInvalidCommand = async (t, commandArgument, execaMethod) => {Rename files (#977)ehmickybefore adoption4b2e316
line 47why, one step back47 t.throws(() => {Upgrade xo (#980)ehmickybefore adoptionccfa412
line 48why, one step back48 execaMethod(commandArgument);Rename files (#977)ehmickybefore adoption4b2e316
lines 49–74why, one step back49 }, {message: /First argument must be a string or a file URL/});50};5152test('execa()\'s first argument must be defined', testInvalidCommand, undefined, execa);53test('execaSync()\'s first argument must be defined', testInvalidCommand, undefined, execaSync);54test('execaCommand()\'s first argument must be defined', testInvalidCommand, undefined, execaCommand);55test('execaCommandSync()\'s first argument must be defined', testInvalidCommand, undefined, execaCommandSync);56test('execaNode()\'s first argument must be defined', testInvalidCommand, undefined, execaNode);57test('$\'s first argument must be defined', testInvalidCommand, undefined, $);58test('$.sync\'s first argument must be defined', testInvalidCommand, undefined, $.sync);59test('execa()\'s first argument must be valid', testInvalidCommand, true, execa);60test('execaSync()\'s first argument must be valid', testInvalidCommand, true, execaSync);61test('execaCommand()\'s first argument must be valid', testInvalidCommand, true, execaCommand);62test('execaCommandSync()\'s first argument must be valid', testInvalidCommand, true, execaCommandSync);63test('execaNode()\'s first argument must be valid', testInvalidCommand, true, execaNode);64test('$\'s first argument must be valid', testInvalidCommand, true, $);65test('$.sync\'s first argument must be valid', testInvalidCommand, true, $.sync);66test('execa()\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], execa);67test('execaSync()\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], execaSync);68test('execaCommand()\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], execaCommand);69test('execaCommandSync()\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], execaCommandSync);70test('execaNode()\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], execaNode);71test('$\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], $);72test('$.sync\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], $.sync);7374const testRelativePath = async (t, execaMethod) => {Upgrade xo (#980)ehmickybefore adoptionccfa412
lines 75–77why, one step back75 const rootDirectory = basename(fileURLToPath(new URL('../..', import.meta.url)));76 const pathViaParentDirectory = join('..', rootDirectory, 'test', 'fixtures', 'noop.js');77 const {stdout} = await execaMethod(pathViaParentDirectory);Rename files (#977)ehmickybefore adoption4b2e316
lines 78–87why, one step back78 t.is(stdout, foobarString);79};8081test('execa() use relative path with \'..\' chars', testRelativePath, execa);82test('execaSync() use relative path with \'..\' chars', testRelativePath, execaSync);83test('execaCommand() use relative path with \'..\' chars', testRelativePath, execaCommand);84test('execaCommandSync() use relative path with \'..\' chars', testRelativePath, execaCommandSync);85test('execaNode() use relative path with \'..\' chars', testRelativePath, execaNode);86test('$ use relative path with \'..\' chars', testRelativePath, $);87test('$.sync use relative path with \'..\' chars', testRelativePath, $.sync);