Skip to content
Myr

Make `preferLocal` default to `true` with `$` (#529)

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

authored by ehmicky · committed by GitHub · parent 2c58762 · Browse files · 4 files+8 added−4 removed
This commit

State

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

Diff stats

4 files+8 added−4 removed

  • tests:+5 added−1 removed
  • other:+3 added−3 removed

4 files+8 added−4 removed

modified:test/test.js+5 added-1 removed
2 unmodified lines
3import {fileURLToPath, pathToFileURL} from 'node:url';4import test from 'ava';5import isRunning from 'is-running';6import getNode from 'get-node';7import {execa, execaSync} from '../index.js';7import {execa, execaSync, $} from '../index.js';8import {setFixtureDir, PATH_KEY} from './helpers/fixtures-dir.js';910setFixtureDir();11process.env.FOO = 'foo';
83 unmodified lines
95test('preferLocal: undefined', async t => {96 await t.throwsAsync(execa('ava', ['--version'], {env: getPathWithoutLocalDir()}), {message: ENOENT_REGEXP});97});9899test('preferLocal: undefined with $', async t => {100 await t.notThrowsAsync($({env: getPathWithoutLocalDir()})`ava --version`);101});102103test('localDir option', async t => {104 const command = process.platform === 'win32' ? 'echo %PATH%' : 'echo $PATH';105 const {stdout} = await execa(command, {shell: true, preferLocal: true, localDir: '/test'});106 const envPaths = stdout.split(path.delimiter);
153 unmodified lines
modified:index.d.ts+1 added-1 removed
25 unmodified lines
26 Prefer locally installed binaries when looking for a binary to execute.2728 If you `$ npm install foo`, you can then `execa('foo')`.2930 @default false30 @default `true` with `$`/`$.sync`, `false` otherwise31 */32 readonly preferLocal?: boolean;3334 /**
684 unmodified lines
modified:index.js+1 added-1 removed
240 unmodified lines
241242 return $;243}244245export const $ = create$();245export const $ = create$({preferLocal: true});246247export function execaCommand(command, options) {248 const [file, ...args] = parseCommand(command);249 return execa(file, args, options);
38 unmodified lines
modified:readme.md+1 added-1 removed
423 unmodified lines
424425#### preferLocal426427Type: `boolean`\428Default: `false`428Default: `true` with [`$`](#command)/[`$.sync`](#synccommand), `false` otherwise429430Prefer locally installed binaries when looking for a binary to execute.\431If you `$ npm install foo`, you can then `execa('foo')`.432
305 unmodified lines