parameters-command.js
This file
Path
test/methods/parameters-command.js
76 lines · 4.2 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
The walk stopped after 200 commits: lines older than 08eb743 point at it.
TweaksSindre Sorhusbefore adoption698a1b8
line 1why, one step back1import assert from 'node:assert/strict';Upgrade dependencies (#1138)ehmickybefore adoptionabd9fd0
line 2why, one step back2import path from 'node:path';Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 3why, one step back3import {fileURLToPath} from 'node:url';TweaksSindre Sorhusbefore adoption698a1b8
lines 4–5why, one step back4import test from 'node:test';5import {assertThrows} from '../helpers/assert.js';Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 6–16why, one step back6import {7 execa,8 execaSync,9 execaNode,10 $,11} from '../../index.js';12import {setFixtureDirectory, FIXTURES_DIRECTORY_URL} from '../helpers/fixtures-directory.js';13import {foobarString} from '../helpers/input.js';1415setFixtureDirectory();16TweaksSindre Sorhusbefore adoption698a1b8
line 17why, one step back17const testFileUrl = async execaMethod => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 18–19why, one step back18 const command = new URL('noop.js', FIXTURES_DIRECTORY_URL);19 const {stdout} = await execaMethod(command);TweaksSindre Sorhusbefore adoption698a1b8
line 20why, one step back20 assert.equal(stdout, foobarString);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 21–22why, one step back21};22TweaksSindre Sorhusbefore adoption698a1b8
lines 23–27why, one step back23test('execa()\'s command argument can be a file URL', () => testFileUrl(execa));24test('execaSync()\'s command argument can be a file URL', () => testFileUrl(execaSync));25test('execaNode()\'s command argument can be a file URL', () => testFileUrl(execaNode));26test('$\'s command argument can be a file URL', () => testFileUrl($));27test('$.sync\'s command argument can be a file URL', () => testFileUrl($.sync));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 28why, one step back28TweaksSindre Sorhusbefore adoption698a1b8
line 29why, one step back29const testInvalidFileUrl = async execaMethod => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 30why, one step back30 const invalidUrl = new URL('https://invalid.com');TweaksSindre Sorhusbefore adoption698a1b8
line 31why, one step back31 assertThrows(() => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 32–35why, one step back32 execaMethod(invalidUrl);33 }, {code: 'ERR_INVALID_URL_SCHEME'});34};35TweaksSindre Sorhusbefore adoption698a1b8
lines 36–40why, one step back36test('execa()\'s command argument cannot be a non-file URL', () => testInvalidFileUrl(execa));37test('execaSync()\'s command argument cannot be a non-file URL', () => testInvalidFileUrl(execaSync));38test('execaNode()\'s command argument cannot be a non-file URL', () => testInvalidFileUrl(execaNode));39test('$\'s command argument cannot be a non-file URL', () => testInvalidFileUrl($));40test('$.sync\'s command argument cannot be a non-file URL', () => testInvalidFileUrl($.sync));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 41why, one step back41TweaksSindre Sorhusbefore adoption698a1b8
lines 42–43why, one step back42const testInvalidCommand = async (commandArgument, execaMethod) => {43 assertThrows(() => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 44–47why, one step back44 execaMethod(commandArgument);45 }, {message: /First argument must be a string or a file URL/});46};47TweaksSindre Sorhusbefore adoption698a1b8
lines 48–62why, one step back48test('execa()\'s first argument must be defined', () => testInvalidCommand(undefined, execa));49test('execaSync()\'s first argument must be defined', () => testInvalidCommand(undefined, execaSync));50test('execaNode()\'s first argument must be defined', () => testInvalidCommand(undefined, execaNode));51test('$\'s first argument must be defined', () => testInvalidCommand(undefined, $));52test('$.sync\'s first argument must be defined', () => testInvalidCommand(undefined, $.sync));53test('execa()\'s first argument must be valid', () => testInvalidCommand(true, execa));54test('execaSync()\'s first argument must be valid', () => testInvalidCommand(true, execaSync));55test('execaNode()\'s first argument must be valid', () => testInvalidCommand(true, execaNode));56test('$\'s first argument must be valid', () => testInvalidCommand(true, $));57test('$.sync\'s first argument must be valid', () => testInvalidCommand(true, $.sync));58test('execa()\'s command argument must be a string or file URL', () => testInvalidCommand(['command', 'arg'], execa));59test('execaSync()\'s command argument must be a string or file URL', () => testInvalidCommand(['command', 'arg'], execaSync));60test('execaNode()\'s command argument must be a string or file URL', () => testInvalidCommand(['command', 'arg'], execaNode));61test('$\'s command argument must be a string or file URL', () => testInvalidCommand(['command', 'arg'], $));62test('$.sync\'s command argument must be a string or file URL', () => testInvalidCommand(['command', 'arg'], $.sync));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 63why, one step back63TweaksSindre Sorhusbefore adoption698a1b8
line 64why, one step back64const testRelativePath = async execaMethod => {Add more code comments (#984)ehmickybefore adoptionfdd8a9f
line 65why, one step back65 // @todo: use import.meta.dirname after dropping support for Node <20.11.0Upgrade dependencies (#1138)ehmickybefore adoptionabd9fd0
lines 66–67why, one step back66 const rootDirectory = path.basename(fileURLToPath(new URL('../..', import.meta.url)));67 const pathViaParentDirectory = path.join('..', rootDirectory, 'test', 'fixtures', 'noop.js');Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 68why, one step back68 const {stdout} = await execaMethod(pathViaParentDirectory);TweaksSindre Sorhusbefore adoption698a1b8
line 69why, one step back69 assert.equal(stdout, foobarString);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 70–71why, one step back70};71TweaksSindre Sorhusbefore adoption698a1b8
lines 72–76why, one step back72test('execa() use relative path with \'..\' chars', () => testRelativePath(execa));73test('execaSync() use relative path with \'..\' chars', () => testRelativePath(execaSync));74test('execaNode() use relative path with \'..\' chars', () => testRelativePath(execaNode));75test('$ use relative path with \'..\' chars', () => testRelativePath($));76test('$.sync use relative path with \'..\' chars', () => testRelativePath($.sync));