1 | import {debuglog} from 'node:util';
|
2 | import process from 'node:process';
|
3 |
|
4 | export const verboseDefault = debuglog('execa').enabled;
|
5 |
|
6 | const padField = (field, padding) => String(field).padStart(padding, '0');
|
7 |
|
8 | const 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 |
|
13 | export const logCommand = (escapedCommand, {verbose}) => {
|
14 | if (!verbose) {
|
15 | return;
|
16 | }
|
17 |
|
18 | process.stderr.write(`[${getTimestamp()}] ${escapedCommand}\n`);
|
19 | };
|