Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import {$} from './index.js' | ||
Check failure on line 1 in a.js GitHub Actions / Node.js 18 on ubuntu-latest
Check failure on line 1 in a.js GitHub Actions / Node.js 18 on macos-latest
Check failure on line 1 in a.js GitHub Actions / Node.js 18 on windows-latest
Check failure on line 1 in a.js GitHub Actions / Node.js 16 on ubuntu-latest
Check failure on line 1 in a.js GitHub Actions / Node.js 16 on macos-latest
Check failure on line 1 in a.js GitHub Actions / Node.js 16 on windows-latest
Check failure on line 1 in a.js GitHub Actions / Node.js 14 on ubuntu-latest
Check failure on line 1 in a.js GitHub Actions / Node.js 14 on macos-latest
Check failure on line 1 in a.js GitHub Actions / Node.js 14 on windows-latest
Check failure on line 1 in a.js GitHub Actions / Node.js 18 on ubuntu-latest
Check failure on line 1 in a.js GitHub Actions / Node.js 18 on macos-latest
Check failure on line 1 in a.js GitHub Actions / Node.js 18 on windows-latest
Check failure on line 1 in a.js GitHub Actions / Node.js 16 on ubuntu-latest
Check failure on line 1 in a.js GitHub Actions / Node.js 16 on macos-latest
Check failure on line 1 in a.js GitHub Actions / Node.js 16 on windows-latest
Check failure on line 1 in a.js GitHub Actions / Node.js 14 on ubuntu-latest
Check failure on line 1 in a.js GitHub Actions / Node.js 14 on macos-latest
|
||
|
||
const $$ = $({ stdio: 'inherit' }) | ||
Check failure on line 3 in a.js GitHub Actions / Node.js 18 on ubuntu-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 18 on ubuntu-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 18 on ubuntu-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 18 on macos-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 18 on macos-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 18 on macos-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 18 on windows-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 18 on windows-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 18 on windows-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 16 on ubuntu-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 16 on ubuntu-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 16 on ubuntu-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 16 on macos-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 16 on macos-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 16 on macos-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 16 on windows-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 16 on windows-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 16 on windows-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 14 on ubuntu-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 14 on ubuntu-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 14 on ubuntu-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 14 on macos-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 14 on macos-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 14 on macos-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 14 on windows-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 14 on windows-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 14 on windows-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 18 on ubuntu-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 18 on ubuntu-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 18 on ubuntu-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 18 on macos-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 18 on macos-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 18 on macos-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 18 on windows-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 18 on windows-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 18 on windows-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 16 on ubuntu-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 16 on ubuntu-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 16 on ubuntu-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 16 on macos-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 16 on macos-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 16 on macos-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 16 on windows-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 16 on windows-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 16 on windows-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 14 on ubuntu-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 14 on ubuntu-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 14 on ubuntu-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 14 on macos-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 14 on macos-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 14 on macos-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 14 on windows-latest
Check failure on line 3 in a.js GitHub Actions / Node.js 14 on windows-latest
|
||
|
||
await $$`echo one` | ||
Check failure on line 5 in a.js GitHub Actions / Node.js 18 on ubuntu-latest
Check failure on line 5 in a.js GitHub Actions / Node.js 18 on macos-latest
Check failure on line 5 in a.js GitHub Actions / Node.js 18 on windows-latest
Check failure on line 5 in a.js GitHub Actions / Node.js 16 on ubuntu-latest
Check failure on line 5 in a.js GitHub Actions / Node.js 16 on macos-latest
Check failure on line 5 in a.js GitHub Actions / Node.js 16 on windows-latest
Check failure on line 5 in a.js GitHub Actions / Node.js 14 on ubuntu-latest
Check failure on line 5 in a.js GitHub Actions / Node.js 14 on macos-latest
Check failure on line 5 in a.js GitHub Actions / Node.js 14 on windows-latest
Check failure on line 5 in a.js GitHub Actions / Node.js 18 on ubuntu-latest
Check failure on line 5 in a.js GitHub Actions / Node.js 18 on macos-latest
Check failure on line 5 in a.js GitHub Actions / Node.js 18 on windows-latest
Check failure on line 5 in a.js GitHub Actions / Node.js 16 on ubuntu-latest
Check failure on line 5 in a.js GitHub Actions / Node.js 16 on macos-latest
Check failure on line 5 in a.js GitHub Actions / Node.js 16 on windows-latest
Check failure on line 5 in a.js GitHub Actions / Node.js 14 on ubuntu-latest
Check failure on line 5 in a.js GitHub Actions / Node.js 14 on macos-latest
|
||
await $$`echo two` | ||
Check failure on line 6 in a.js GitHub Actions / Node.js 18 on ubuntu-latest
Check failure on line 6 in a.js GitHub Actions / Node.js 18 on macos-latest
Check failure on line 6 in a.js GitHub Actions / Node.js 18 on windows-latest
Check failure on line 6 in a.js GitHub Actions / Node.js 16 on ubuntu-latest
Check failure on line 6 in a.js GitHub Actions / Node.js 16 on macos-latest
Check failure on line 6 in a.js GitHub Actions / Node.js 16 on windows-latest
Check failure on line 6 in a.js GitHub Actions / Node.js 14 on ubuntu-latest
Check failure on line 6 in a.js GitHub Actions / Node.js 14 on macos-latest
Check failure on line 6 in a.js GitHub Actions / Node.js 14 on windows-latest
Check failure on line 6 in a.js GitHub Actions / Node.js 18 on ubuntu-latest
Check failure on line 6 in a.js GitHub Actions / Node.js 18 on macos-latest
Check failure on line 6 in a.js GitHub Actions / Node.js 18 on windows-latest
Check failure on line 6 in a.js GitHub Actions / Node.js 16 on ubuntu-latest
Check failure on line 6 in a.js GitHub Actions / Node.js 16 on macos-latest
Check failure on line 6 in a.js GitHub Actions / Node.js 16 on windows-latest
Check failure on line 6 in a.js GitHub Actions / Node.js 14 on ubuntu-latest
Check failure on line 6 in a.js GitHub Actions / Node.js 14 on macos-latest
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {debuglog} from 'node:util'; | ||
import process from 'node:process'; | ||
|
||
export const verboseDefault = debuglog('execa').enabled; | ||
|
||
const padField = (field, padding) => String(field).padStart(padding, '0'); | ||
|
||
const getTimestamp = () => { | ||
const date = new Date(); | ||
return `${padField(date.getHours(), 2)}:${padField(date.getMinutes(), 2)}:${padField(date.getSeconds(), 2)}.${padField(date.getMilliseconds(), 3)}`; | ||
}; | ||
|
||
export const logCommand = (escapedCommand, {verbose}) => { | ||
if (!verbose) { | ||
return; | ||
} | ||
|
||
process.stderr.write(`[${getTimestamp()}] ${escapedCommand}\n`); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env node | ||
import process from 'node:process'; | ||
import {execa} from '../../index.js'; | ||
|
||
const [options, file, ...args] = process.argv.slice(2); | ||
const nestedOptions = {stdio: 'inherit', ...JSON.parse(options)}; | ||
await execa(file, args, nestedOptions); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env node | ||
import {$} from '../../index.js'; | ||
|
||
const $$ = $({stdio: 'inherit'}); | ||
await $$`echo one`; | ||
await $$`echo two`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import test from 'ava'; | ||
import {execa} from '../index.js'; | ||
import {setFixtureDir} from './helpers/fixtures-dir.js'; | ||
|
||
setFixtureDir(); | ||
|
||
const normalizeTimestamp = output => output.replace(/\d/g, '0'); | ||
const testTimestamp = '[00:00:00.000]'; | ||
|
||
test('Prints command when "verbose" is true', async t => { | ||
const {stdout, stderr, all} = await execa('nested.js', [JSON.stringify({verbose: true}), 'noop.js', 'test'], {all: true}); | ||
t.is(stdout, 'test'); | ||
t.is(normalizeTimestamp(stderr), `${testTimestamp} noop.js test`); | ||
t.is(normalizeTimestamp(all), `${testTimestamp} noop.js test\ntest`); | ||
}); | ||
|
||
test('Prints command with NODE_DEBUG=execa', async t => { | ||
const {stdout, stderr, all} = await execa('nested.js', [JSON.stringify({}), 'noop.js', 'test'], {all: true, env: {NODE_DEBUG: 'execa'}}); | ||
t.is(stdout, 'test'); | ||
t.is(normalizeTimestamp(stderr), `${testTimestamp} noop.js test`); | ||
t.is(normalizeTimestamp(all), `${testTimestamp} noop.js test\ntest`); | ||
}); | ||
|
||
test('Escape verbose command', async t => { | ||
const {stderr} = await execa('nested.js', [JSON.stringify({verbose: true}), 'noop.js', 'one two', '"'], {all: true}); | ||
t.true(stderr.endsWith('"one two" "\\""')); | ||
}); | ||
|
||
test('Verbose option works with inherit', async t => { | ||
const {all} = await execa('verbose-script.js', {all: true, env: {NODE_DEBUG: 'execa'}}); | ||
t.is(normalizeTimestamp(all), `${testTimestamp} echo one | ||
one | ||
${testTimestamp} echo two | ||
two`); | ||
}); |