版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

20 lines
575 B

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