@stacksjs/launchpad
Version:
Like Homebrew, but faster.
3 lines (2 loc) • 787 B
JavaScript
import{ab as u}from"./chunk-b9hx8gsj.js";import q from"fs";import{homedir as v}from"os";import j from"path";class k{string;constructor(b){this.string=b}static home(){return new k(v())}join(...b){return new k(j.join(this.string,...b))}isDirectory(){try{return q.statSync(this.string).isDirectory()}catch{return!1}}exists(){return q.existsSync(this.string)}parent(){return new k(j.dirname(this.string))}basename(){return j.basename(this.string)}relative({to:b}){return j.relative(b.string,this.string)}async*ls(){try{for(let b of q.readdirSync(this.string,{withFileTypes:!0}))yield[new k(j.join(this.string,b.name)),{name:b.name,isDirectory:b.isDirectory(),isSymlink:b.isSymbolicLink()}]}catch(b){if(u.verbose)console.error(`Error reading directory ${this.string}:`,b)}}}
export{k as Ya};