Skip to content
Myr

parameters-command.js

This file

Path

test/methods/parameters-command.js

88 lines · 5.2 KiB · JavaScript

Last changed by

Upgrade dependencies (#1138)ehmickybefore adoptionabd9fd0

History of this file

Take it

Upgrade dependencies (#1138)ehmickybefore adoptionabd9fd0

line 1why, one step back
1import path from 'node:path';

Rename files (#977)ehmickybefore adoption4b2e316

lines 2–3why, one step back
2import {fileURLToPath} from 'node:url';
3import test from 'ava';

Upgrade xo (#980)ehmickybefore adoptionccfa412

lines 4–12why, one step back
4import {
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 back
13import {foobarString} from '../helpers/input.js';
14

Upgrade xo (#980)ehmickybefore adoptionccfa412

line 15why, one step back
15setFixtureDirectory();

Rename files (#977)ehmickybefore adoption4b2e316

lines 16–17why, one step back
16
17const testFileUrl = async (t, execaMethod) => {

Upgrade xo (#980)ehmickybefore adoptionccfa412

line 18why, one step back
18 const command = new URL('noop.js', FIXTURES_DIRECTORY_URL);

Rename files (#977)ehmickybefore adoption4b2e316

lines 19–45why, one step back
19 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);45

Upgrade xo (#980)ehmickybefore adoptionccfa412

line 46why, one step back
46const testInvalidCommand = async (t, commandArgument, execaMethod) => {

Rename files (#977)ehmickybefore adoption4b2e316

line 47why, one step back
47 t.throws(() => {

Upgrade xo (#980)ehmickybefore adoptionccfa412

line 48why, one step back
48 execaMethod(commandArgument);

Rename files (#977)ehmickybefore adoption4b2e316

lines 49–74why, one step back
49 }, {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) => {

Add more code comments (#984)ehmickybefore adoptionfdd8a9f

line 75why, one step back
75 // @todo: use import.meta.dirname after dropping support for Node <20.11.0

Upgrade dependencies (#1138)ehmickybefore adoptionabd9fd0

lines 76–77why, one step back
76 const rootDirectory = path.basename(fileURLToPath(new URL('../..', import.meta.url)));
77 const pathViaParentDirectory = path.join('..', rootDirectory, 'test', 'fixtures', 'noop.js');

Upgrade xo (#980)ehmickybefore adoptionccfa412

line 78why, one step back
78 const {stdout} = await execaMethod(pathViaParentDirectory);

Rename files (#977)ehmickybefore adoption4b2e316

lines 79–88why, one step back
79 t.is(stdout, foobarString);
80};8182test('execa() use relative path with \'..\' chars', testRelativePath, execa);83test('execaSync() use relative path with \'..\' chars', testRelativePath, execaSync);84test('execaCommand() use relative path with \'..\' chars', testRelativePath, execaCommand);85test('execaCommandSync() use relative path with \'..\' chars', testRelativePath, execaCommandSync);86test('execaNode() use relative path with \'..\' chars', testRelativePath, execaNode);87test('$ use relative path with \'..\' chars', testRelativePath, $);88test('$.sync use relative path with \'..\' chars', testRelativePath, $.sync);