command.js 777 B

1234567891011121314151617181920
  1. import {logCommand} from '../verbose/start.js';
  2. import {getVerboseInfo} from '../verbose/info.js';
  3. import {getStartTime} from '../return/duration.js';
  4. import {joinCommand} from './escape.js';
  5. import {normalizeFdSpecificOption} from './specific.js';
  6. // Compute `result.command`, `result.escapedCommand` and `verbose`-related information
  7. export const handleCommand = (filePath, rawArguments, rawOptions) => {
  8. const startTime = getStartTime();
  9. const {command, escapedCommand} = joinCommand(filePath, rawArguments);
  10. const verbose = normalizeFdSpecificOption(rawOptions, 'verbose');
  11. const verboseInfo = getVerboseInfo(verbose, escapedCommand, {...rawOptions});
  12. logCommand(escapedCommand, verboseInfo);
  13. return {
  14. command,
  15. escapedCommand,
  16. startTime,
  17. verboseInfo,
  18. };
  19. };