UNPKG

575 BJavaScriptView Raw
1import {debuglog} from 'node:util';
2import process from 'node:process';
3
4export const verboseDefault = debuglog('execa').enabled;
5
6const padField = (field, padding) => String(field).padStart(padding, '0');
7
8const getTimestamp = () => {
9 const date = new Date();
10 return `${padField(date.getHours(), 2)}:${padField(date.getMinutes(), 2)}:${padField(date.getSeconds(), 2)}.${padField(date.getMilliseconds(), 3)}`;
11};
12
13export const logCommand = (escapedCommand, {verbose}) => {
14 if (!verbose) {
15 return;
16 }
17
18 process.stderr.write(`[${getTimestamp()}] ${escapedCommand}\n`);
19};