Skip to content
Myr

Upgrade dependencies (#1138)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by GitHub · parent f9f7140 · Browse files · 16 files+48 added−45 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

16 files+48 added−45 removed

  • tests:+37 added−34 removed
  • other:+11 added−11 removed

16 files+48 added−45 removed

modified:lib/arguments/cwd.js+2 added-2 removed
modified:lib/arguments/options.js+2 added-2 removed
modified:lib/methods/node.js+3 added-3 removed
modified:test/arguments/cwd.js+4 added-4 removed
1import {mkdir, rmdir} from 'node:fs/promises';2import {relative, toNamespacedPath} from 'node:path';2import path from 'node:path';3import process from 'node:process';4import {pathToFileURL, fileURLToPath} from 'node:url';5import tempfile from 'tempfile';6import test from 'ava';
6 unmodified lines
1314const testOptionCwdString = async (t, execaMethod) => {15 const cwd = '/';16 const {stdout} = await execaMethod('node', ['-p', 'process.cwd()'], {cwd});17 t.is(toNamespacedPath(stdout), toNamespacedPath(cwd));17 t.is(path.toNamespacedPath(stdout), path.toNamespacedPath(cwd));18};1920test('The "cwd" option can be a string', testOptionCwdString, execa);21test('The "cwd" option can be a string - sync', testOptionCwdString, execaSync);
1 unmodified line
23const testOptionCwdUrl = async (t, execaMethod) => {24 const cwd = '/';25 const cwdUrl = pathToFileURL(cwd);26 const {stdout} = await execaMethod('node', ['-p', 'process.cwd()'], {cwd: cwdUrl});27 t.is(toNamespacedPath(stdout), toNamespacedPath(cwd));27 t.is(path.toNamespacedPath(stdout), path.toNamespacedPath(cwd));28};2930test('The "cwd" option can be a URL', testOptionCwdUrl, execa);31test('The "cwd" option can be a URL - sync', testOptionCwdUrl, execaSync);
60 unmodified lines
92const successProperties = {fixtureName: 'empty.js', expectedFailed: false};93const errorProperties = {fixtureName: 'fail.js', expectedFailed: true};9495const testErrorCwd = async (t, execaMethod, {fixtureName, expectedFailed}) => {96 const {failed, cwd} = await execaMethod(fixtureName, {cwd: relative('.', FIXTURES_DIRECTORY), reject: false});96 const {failed, cwd} = await execaMethod(fixtureName, {cwd: path.relative('.', FIXTURES_DIRECTORY), reject: false});97 t.is(failed, expectedFailed);98 t.is(cwd, FIXTURES_DIRECTORY);99};100
4 unmodified lines
modified:test/arguments/local.js+6 added-4 removed
1import {delimiter} from 'node:path';1import path from 'node:path';2import process from 'node:process';3import {pathToFileURL} from 'node:url';4import test from 'ava';5import {execa, $} from '../../index.js';
5 unmodified lines
11const isWindows = process.platform === 'win32';12const ENOENT_REGEXP = isWindows ? /failed with exit code 1/ : /spawn.* ENOENT/;1314const getPathWithoutLocalDirectory = () => {15 const newPath = process.env[PATH_KEY].split(delimiter).filter(pathDirectory => !BIN_DIR_REGEXP.test(pathDirectory)).join(delimiter);15 const newPath = process.env[PATH_KEY]16 .split(path.delimiter)17 .filter(pathDirectory => !BIN_DIR_REGEXP.test(pathDirectory)).join(path.delimiter);18 return {[PATH_KEY]: newPath};19};2021const BIN_DIR_REGEXP = /node_modules[\\/]\.bin/;
38 unmodified lines
6061test('localDir option', async t => {62 const command = isWindows ? 'echo %PATH%' : 'echo $PATH';63 const {stdout} = await execa(command, {shell: true, preferLocal: true, localDir: '/test'});62 const envPaths = stdout.split(delimiter);64 const envPaths = stdout.split(path.delimiter);65 t.true(envPaths.some(envPath => envPath.endsWith('.bin')));66});6768test('localDir option can be a URL', async t => {69 const command = isWindows ? 'echo %PATH%' : 'echo $PATH';70 const {stdout} = await execa(command, {shell: true, preferLocal: true, localDir: pathToFileURL('/test')});69 const envPaths = stdout.split(delimiter);71 const envPaths = stdout.split(path.delimiter);72 t.true(envPaths.some(envPath => envPath.endsWith('.bin')));73});
modified:test/helpers/file-path.js+2 added-2 removed
modified:test/helpers/fixtures-directory.js+3 added-3 removed
1import {delimiter, resolve} from 'node:path';1import path from 'node:path';2import process from 'node:process';3import {fileURLToPath} from 'node:url';4import pathKey from 'path-key';56export const PATH_KEY = pathKey();7export const FIXTURES_DIRECTORY_URL = new URL('../fixtures/', import.meta.url);8// @todo: use import.meta.dirname after dropping support for Node <20.11.09export const FIXTURES_DIRECTORY = resolve(fileURLToPath(FIXTURES_DIRECTORY_URL));9export const FIXTURES_DIRECTORY = path.resolve(fileURLToPath(FIXTURES_DIRECTORY_URL));1011// Add the fixtures directory to PATH so fixtures can be executed without adding12// `node`. This is only meant to make writing tests simpler.13export const setFixtureDirectory = () => {14 process.env[PATH_KEY] = FIXTURES_DIRECTORY + delimiter + process.env[PATH_KEY];14 process.env[PATH_KEY] = FIXTURES_DIRECTORY + path.delimiter + process.env[PATH_KEY];15};16
modified:test/methods/bind.js+3 added-3 removed
1import {join} from 'node:path';1import path from 'node:path';2import test from 'ava';3import {4 execa,5 execaSync,
5 unmodified lines
11import {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';1213setFixtureDirectory();1415const NOOP_PATH = join(FIXTURES_DIRECTORY, 'noop.js');16const PRINT_ENV_PATH = join(FIXTURES_DIRECTORY, 'environment.js');15const NOOP_PATH = path.join(FIXTURES_DIRECTORY, 'noop.js');16const PRINT_ENV_PATH = path.join(FIXTURES_DIRECTORY, 'environment.js');1718const testBindOptions = async (t, execaMethod) => {19 const {stdout} = await execaMethod({stripFinalNewline: false})(NOOP_PATH, [foobarString]);20 t.is(stdout, `${foobarString}\n`);
89 unmodified lines
modified:test/methods/command.js+2 added-2 removed
1import {join} from 'node:path';1import path from 'node:path';2import test from 'ava';3import {4 execa,5 execaSync,
10 unmodified lines
16} from '../helpers/fixtures-directory.js';17import {QUOTE} from '../helpers/verbose.js';1819setFixtureDirectory();20const STDIN_FIXTURE = join(FIXTURES_DIRECTORY, 'stdin.js');20const STDIN_FIXTURE = path.join(FIXTURES_DIRECTORY, 'stdin.js');21const ECHO_FIXTURE_URL = new URL('echo.js', FIXTURES_DIRECTORY_URL);2223const parseAndRunCommand = command => execa`${parseCommandString(command)}`;24
175 unmodified lines
modified:test/methods/create.js+2 added-2 removed
1import {join} from 'node:path';1import path from 'node:path';2import test from 'ava';3import {4 execa,5 execaSync,
4 unmodified lines
10import {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';1112setFixtureDirectory();1314const NOOP_PATH = join(FIXTURES_DIRECTORY, 'noop.js');14const NOOP_PATH = path.join(FIXTURES_DIRECTORY, 'noop.js');1516const testTemplate = async (t, execaMethod) => {17 const {stdout} = await execaMethod`${NOOP_PATH} ${foobarString}`;18 t.is(stdout, foobarString);
45 unmodified lines
modified:test/methods/node.js+6 added-6 removed
1import {dirname, relative} from 'node:path';1import path from 'node:path';2import process, {version} from 'node:process';3import {pathToFileURL} from 'node:url';4import test from 'ava';5import getNode from 'get-node';
130 unmodified lines
136test.serial('The "nodePath" option impacts the subprocess - "node" option sync', testSubprocessNodePath, runWithNodeOptionSync, identity);137138const testSubprocessNodePathDefault = async (t, execaMethod) => {139 const {stdout} = await execaMethod(...nodePathArguments);140 t.true(stdout.includes(dirname(process.execPath)));140 t.true(stdout.includes(path.dirname(process.execPath)));141};142143test('The "nodePath" option defaults to the current Node.js binary in the subprocess - execaNode()', testSubprocessNodePathDefault, execaNode);144test('The "nodePath" option defaults to the current Node.js binary in the subprocess - "node" option', testSubprocessNodePathDefault, runWithNodeOption);
6 unmodified lines
151});152153const testSubprocessNodePathCwd = async (t, execaMethod) => {154 const nodePath = await getNodePath();155 const cwd = dirname(dirname(nodePath));156 const relativeExecPath = relative(cwd, nodePath);155 const cwd = path.dirname(path.dirname(nodePath));156 const relativeExecPath = path.relative(cwd, nodePath);157 const {stdout} = await execaMethod(...nodePathArguments, {nodePath: relativeExecPath, cwd});158 t.true(stdout.includes(TEST_NODE_VERSION));159};160
2 unmodified lines
163test.serial('The "nodePath" option is relative to "cwd" when used in the subprocess - "node" option sync', testSubprocessNodePathCwd, runWithNodeOptionSync);164165const testCwdNodePath = async (t, execaMethod) => {166 const nodePath = await getNodePath();167 const cwd = dirname(dirname(nodePath));168 const relativeExecPath = relative(cwd, nodePath);167 const cwd = path.dirname(path.dirname(nodePath));168 const relativeExecPath = path.relative(cwd, nodePath);169 const {stdout} = await execaMethod('--version', [], {nodePath: relativeExecPath, cwd});170 t.is(stdout, `v${TEST_NODE_VERSION}`);171};172
116 unmodified lines
modified:test/methods/parameters-command.js+3 added-3 removed
1import {join, basename} from 'node:path';1import path from 'node:path';2import {fileURLToPath} from 'node:url';3import test from 'ava';4import {5 execa,
66 unmodified lines
72test('$.sync\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], $.sync);7374const testRelativePath = async (t, execaMethod) => {75 // @todo: use import.meta.dirname after dropping support for Node <20.11.076 const rootDirectory = basename(fileURLToPath(new URL('../..', import.meta.url)));77 const pathViaParentDirectory = join('..', rootDirectory, 'test', 'fixtures', 'noop.js');76 const rootDirectory = path.basename(fileURLToPath(new URL('../..', import.meta.url)));77 const pathViaParentDirectory = path.join('..', rootDirectory, 'test', 'fixtures', 'noop.js');78 const {stdout} = await execaMethod(pathViaParentDirectory);79 t.is(stdout, foobarString);80};81
7 unmodified lines
modified:test/methods/parameters-options.js+2 added-2 removed
1import {join} from 'node:path';1import path from 'node:path';2import test from 'ava';3import {4 execa,5 execaSync,
5 unmodified lines
11import {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';1213setFixtureDirectory();1415const NOOP_PATH = join(FIXTURES_DIRECTORY, 'noop.js');15const NOOP_PATH = path.join(FIXTURES_DIRECTORY, 'noop.js');1617const testSerializeArgument = async (t, commandArgument, execaMethod) => {18 const {stdout} = await execaMethod(NOOP_PATH, [commandArgument]);19 t.is(stdout, String(commandArgument));
56 unmodified lines
modified:test/return/early-error.js+1 added
23 unmodified lines
2425const testEarlyErrorShape = async (t, reject) => {26 const subprocess = getEarlyErrorSubprocess({reject});27 t.notThrows(() => {28 // eslint-disable-next-line promise/prefer-await-to-then29 subprocess.catch(() => {});30 subprocess.unref();31 subprocess.on('error', () => {});32 });
83 unmodified lines
modified:test/stdio/file-path-main.js+3 added-3 removed
1import {readFile, writeFile, rm} from 'node:fs/promises';2import {dirname, basename} from 'node:path';2import path from 'node:path';3import process from 'node:process';4import {pathToFileURL} from 'node:url';5import test from 'ava';6import tempfile from 'tempfile';
75 unmodified lines
82const testInputFileValidUrl = async (t, fdNumber, execaMethod) => {83 const filePath = tempfile();84 await writeFile(filePath, foobarString);85 const currentCwd = process.cwd();86 process.chdir(dirname(filePath));86 process.chdir(path.dirname(filePath));8788 try {89 const {stdout} = await execaMethod('stdin.js', getStdioInputFile(fdNumber, basename(filePath)));89 const {stdout} = await execaMethod('stdin.js', getStdioInputFile(fdNumber, path.basename(filePath)));90 t.is(stdout, foobarString);91 } finally {92 process.chdir(currentCwd);93 await rm(filePath);
67 unmodified lines
modified:package.json+4 added-4 removed
53 unmodified lines
54 "@sindresorhus/merge-streams": "^4.0.0",55 "cross-spawn": "^7.0.3",56 "figures": "^6.1.0",57 "get-stream": "^9.0.0",58 "human-signals": "^7.0.0",58 "human-signals": "^8.0.0",59 "is-plain-obj": "^4.1.0",60 "is-stream": "^4.0.1",61 "npm-run-path": "^5.2.0",62 "pretty-ms": "^9.0.0",
1 unmodified line
64 "strip-final-newline": "^4.0.0",65 "yoctocolors": "^2.0.0"66 },67 "devDependencies": {68 "@types/node": "^20.8.9",68 "@types/node": "^22.1.0",69 "ava": "^6.0.1",70 "c8": "^10.1.2",71 "get-node": "^15.0.0",72 "is-in-ci": "^0.1.0",72 "is-in-ci": "^1.0.0",73 "is-running": "^2.1.0",74 "path-exists": "^5.0.0",75 "path-key": "^4.0.0",76 "tempfile": "^5.0.0",77 "tsd": "^0.31.0",78 "typescript": "^5.4.5",79 "which": "^4.0.0",80 "xo": "^0.58.0"80 "xo": "^0.59.3"81 },82 "c8": {83 "reporter": [84 "text",
20 unmodified lines