Skip to content
Myr

custom-id.js

This file

Path

test/verbose/custom-id.js

36 lines · 2.8 KiB · JavaScript

Last changed by

TweaksSindre Sorhusbefore adoption698a1b8

History of this file

Take it

TweaksSindre Sorhusbefore adoption698a1b8

lines 1–2why, one step back
1import assert from 'node:assert/strict';
2import test from 'node:test';

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

lines 3–7why, one step back
3import {setFixtureDirectory} from '../helpers/fixtures-directory.js';
4import {QUOTE, runVerboseSubprocess} from '../helpers/verbose.js';56setFixtureDirectory();7

TweaksSindre Sorhusbefore adoption698a1b8

line 8why, one step back
8const testVerboseCommandId = async (type, isSync) => {

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

line 9why, one step back
9 const {stderr} = await runVerboseSubprocess({isSync, type, eventProperty: 'commandId'});

TweaksSindre Sorhusbefore adoption698a1b8

line 10why, one step back
10 assert.equal(stderr, '0');

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

lines 11–12why, one step back
11};
12

TweaksSindre Sorhusbefore adoption698a1b8

lines 13–21why, one step back
13test('"verbose" function receives verboseObject.commandId, "command"', () => testVerboseCommandId('command', false));
14test('"verbose" function receives verboseObject.commandId, "output"', () => testVerboseCommandId('output', false));15test('"verbose" function receives verboseObject.commandId, "ipc"', () => testVerboseCommandId('ipc', false));16test('"verbose" function receives verboseObject.commandId, "error"', () => testVerboseCommandId('error', false));17test('"verbose" function receives verboseObject.commandId, "duration"', () => testVerboseCommandId('duration', false));18test('"verbose" function receives verboseObject.commandId, "command", sync', () => testVerboseCommandId('command', true));19test('"verbose" function receives verboseObject.commandId, "output", sync', () => testVerboseCommandId('output', true));20test('"verbose" function receives verboseObject.commandId, "error", sync', () => testVerboseCommandId('error', true));21test('"verbose" function receives verboseObject.commandId, "duration", sync', () => testVerboseCommandId('duration', true));

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

line 22why, one step back
22

TweaksSindre Sorhusbefore adoption698a1b8

line 23why, one step back
23const testVerboseEscapedCommand = async (type, isSync) => {

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

line 24why, one step back
24 const {stderr} = await runVerboseSubprocess({isSync, type, eventProperty: 'escapedCommand'});

TweaksSindre Sorhusbefore adoption698a1b8

line 25why, one step back
25 assert.equal(stderr, `noop-verbose.js ${QUOTE}. .${QUOTE}`);

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

lines 26–27why, one step back
26};
27

TweaksSindre Sorhusbefore adoption698a1b8

lines 28–36why, one step back
28test('"verbose" function receives verboseObject.escapedCommand, "command"', () => testVerboseEscapedCommand('command', false));
29test('"verbose" function receives verboseObject.escapedCommand, "output"', () => testVerboseEscapedCommand('output', false));30test('"verbose" function receives verboseObject.escapedCommand, "ipc"', () => testVerboseEscapedCommand('ipc', false));31test('"verbose" function receives verboseObject.escapedCommand, "error"', () => testVerboseEscapedCommand('error', false));32test('"verbose" function receives verboseObject.escapedCommand, "duration"', () => testVerboseEscapedCommand('duration', false));33test('"verbose" function receives verboseObject.escapedCommand, "command", sync', () => testVerboseEscapedCommand('command', true));34test('"verbose" function receives verboseObject.escapedCommand, "output", sync', () => testVerboseEscapedCommand('output', true));35test('"verbose" function receives verboseObject.escapedCommand, "error", sync', () => testVerboseEscapedCommand('error', true));36test('"verbose" function receives verboseObject.escapedCommand, "duration", sync', () => testVerboseEscapedCommand('duration', true));