UNPKG

gulp-execa

Version:

Gulp.js command execution for humans

43 lines (30 loc) 772 B
import{execa,parseCommandString}from"execa"; import{printEcho}from"./echo.js"; import{throwError}from"./error.js"; import{validateInput}from"./input.js"; import{parseOpts}from"./options/main.js"; export const exec=(input,opts)=>{ validateInput(input); const optsA=parseOpts({opts}); return execCommand(input,optsA) }; export const execCommand=async(input,opts)=>{ printEcho({input,opts}); try{ return await execaCommand(input,opts) }catch(error){ throwError(error) } }; export const streamCommand=(input,opts)=>{ printEcho({input,opts}); try{ return execaCommand(input,opts).readable({from:opts.from}) }catch(error){ throwError(error) } }; const execaCommand=(input,opts)=>{ const[command,...args]=parseCommandString(input); return execa(command,args,opts) };