#!/usr/bin/env node
import{a as d}from"./chunk-JBABAK44.js";import{a as p,b as l}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var h={name:"tee",summary:"read from stdin and write to stdout and files",usage:"tee [OPTION]... [FILE]...",options:["-a, --append     append to the given FILEs, do not overwrite","    --help       display this help and exit"]},m={append:{short:"a",long:"append",type:"boolean"}},g={name:"tee",async execute(r,e){if(l(r))return p(h);let t=d("tee",r,m);if(!t.ok)return t.error;let{append:f}=t.result.flags,c=t.result.positional,o=e.stdin,n="",a=0;for(let i of c)try{let s=e.fs.resolvePath(e.cwd,i);f?await e.fs.appendFile(s,o):await e.fs.writeFile(s,o)}catch{n+=`tee: ${i}: No such file or directory
`,a=1}return{stdout:o,stderr:n,exitCode:a}}};export{g as teeCommand};
