shell.js
This file
Path
test/arguments/shell.js
27 lines · 922 bytes · JavaScript
Last changed by
Upgrade xo (#980)ehmickybefore adoptionccfa412
History of this fileTake it
12345678910111213141516171819202122232425262728import process from 'node:process';import {pathToFileURL} from 'node:url';import test from 'ava';import which from 'which';import {execa} from '../../index.js';import {setFixtureDirectory} from '../helpers/fixtures-directory.js';import {identity} from '../helpers/stdio.js';
setFixtureDirectory();process.env.FOO = 'foo';
const isWindows = process.platform === 'win32';
test('can use `options.shell: true`', async t => { const {stdout} = await execa('node test/fixtures/noop.js foo', {shell: true}); t.is(stdout, 'foo');});
const testShellPath = async (t, mapPath) => { const shellPath = isWindows ? 'cmd.exe' : 'bash'; const shell = mapPath(await which(shellPath)); const {stdout} = await execa('node test/fixtures/noop.js foo', {shell}); t.is(stdout, 'foo');};
test('can use `options.shell: string`', testShellPath, identity);test('can use `options.shell: file URL`', testShellPath, pathToFileURL);