import{n as e}from"./chunk-3THT3N7L-B1WzJUh4.mjs";import{n as t,r as n,t as r}from"./chunk-74CEPOFO-V0JXh91S.mjs";var i={name:`ln`,summary:`make links between files`,usage:`ln [OPTIONS] TARGET LINK_NAME`,options:[`-s      create a symbolic link instead of a hard link`,`-f      remove existing destination files`,`-n      treat LINK_NAME as a normal file if it is a symbolic link to a directory`,`-v      print name of each linked file`,`    --help display this help and exit`]},a={name:`ln`,async execute(a,o){if(r(a))return n(i);let s=!1,c=!1,l=!1,u=0;for(;u<a.length&&a[u].startsWith(`-`);){let e=a[u];if(e===`-s`||e===`--symbolic`)s=!0,u++;else if(e===`-f`||e===`--force`)c=!0,u++;else if(e===`-v`||e===`--verbose`)l=!0,u++;else if(e===`-n`||e===`--no-dereference`)u++;else if(/^-[sfvn]+$/.test(e))e.includes(`s`)&&(s=!0),e.includes(`f`)&&(c=!0),e.includes(`v`)&&(l=!0),u++;else if(e===`--`){u++;break}else return t(`ln`,e)}let d=a.slice(u);if(d.length<2)return{stdout:``,stderr:`ln: missing file operand
`,exitCode:1};let f=d[0],p=d[1],m=o.fs.resolvePath(o.cwd,p);if(await o.fs.exists(m))if(c)try{await o.fs.rm(m,{force:!0})}catch{return{stdout:``,stderr:`ln: cannot remove '${p}': Permission denied
`,exitCode:1}}else return{stdout:``,stderr:`ln: failed to create ${s?`symbolic `:``}link '${p}': File exists
`,exitCode:1};try{if(s)await o.fs.symlink(f,m);else{let e=o.fs.resolvePath(o.cwd,f);if(!await o.fs.exists(e))return{stdout:``,stderr:`ln: failed to access '${f}': No such file or directory
`,exitCode:1};await o.fs.link(e,m)}}catch(t){let n=t;return n.message.includes(`EPERM`)?{stdout:``,stderr:`ln: '${f}': hard link not allowed for directory
`,exitCode:1}:{stdout:``,stderr:`ln: ${e(n.message)}
`,exitCode:1}}let h=``;return l&&(h=`'${p}' -> '${f}'
`),{stdout:h,stderr:``,exitCode:0}}},o={name:`ln`,flags:[{flag:`-s`,type:`boolean`},{flag:`-f`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-v`,type:`boolean`}],needsArgs:!0,minArgs:2};export{a as n,o as t};
//# sourceMappingURL=chunk-PBXLG62G-CpvczNyQ.mjs.map