ccexp
Version:
CLI tool for exploring and managing Claude Code settings and slash commands
133 lines (131 loc) • 3.12 kB
JavaScript
import b from "node:fs";
import c from "node:path";
import a from "node:fs/promises";
import F from "node:os";
//#region node_modules/fs-fixture/dist/index.mjs
var d = Object.defineProperty;
var n = (s, t) => d(s, "name", {
value: t,
configurable: !0
});
typeof Symbol.asyncDispose != "symbol" && Object.defineProperty(Symbol, "asyncDispose", {
configurable: !1,
enumerable: !1,
writable: !1,
value: Symbol.for("asyncDispose")
});
var P = class {
static {
n(this, "FsFixture");
}
path;
constructor(t) {
this.path = t;
}
getPath(...t) {
return c.join(this.path, ...t);
}
exists(t = "") {
return a.access(this.getPath(t)).then(() => !0, () => !1);
}
rm(t = "") {
return a.rm(this.getPath(t), {
recursive: !0,
force: !0
});
}
cp(t, r, i) {
return r ? r.endsWith(c.sep) && (r += c.basename(t)) : r = c.basename(t), a.cp(t, this.getPath(r), i);
}
mkdir(t) {
return a.mkdir(this.getPath(t), { recursive: !0 });
}
writeFile(t, r) {
return a.writeFile(this.getPath(t), r);
}
writeJson(t, r) {
return this.writeFile(t, JSON.stringify(r, null, 2));
}
readFile(t, r) {
return a.readFile(this.getPath(t), r);
}
async [Symbol.asyncDispose]() {
await this.rm();
}
};
const v = b.realpathSync(F.tmpdir()), D = `fs-fixture-${Date.now()}-${process.pid}`;
let m = 0;
const j = n(() => (m += 1, m), "getId");
var u = class {
static {
n(this, "Path");
}
path;
constructor(t) {
this.path = t;
}
};
var f = class extends u {
static {
n(this, "Directory");
}
};
var y = class extends u {
static {
n(this, "File");
}
content;
constructor(t, r) {
super(t), this.content = r;
}
};
var l = class {
static {
n(this, "Symlink");
}
target;
type;
path;
constructor(t, r) {
this.target = t, this.type = r;
}
};
const w = n((s, t, r) => {
const i = [];
for (const p in s) {
if (!Object.hasOwn(s, p)) continue;
const e = c.join(t, p);
let o = s[p];
if (typeof o == "function") {
const g = Object.assign(Object.create(r), { filePath: e }), h = o(g);
if (h instanceof l) {
h.path = e, i.push(h);
continue;
} else o = h;
}
typeof o == "string" ? i.push(new y(e, o)) : i.push(new f(e), ...w(o, e, r));
}
return i;
}, "flattenFileTree"), k = n(async (s, t) => {
const r = t?.tempDir ? c.resolve(t.tempDir) : v, i = c.join(r, `${D}-${j()}/`);
if (await a.mkdir(i, { recursive: !0 }), s) {
if (typeof s == "string") await a.cp(s, i, {
recursive: !0,
filter: t?.templateFilter
});
else if (typeof s == "object") {
const p = {
fixturePath: i,
getPath: n((...e) => c.join(i, ...e), "getPath"),
symlink: n((e, o) => new l(e, o), "symlink")
};
await Promise.all(w(s, i, p).map(async (e) => {
e instanceof f ? await a.mkdir(e.path, { recursive: !0 }) : e instanceof l ? (await a.mkdir(c.dirname(e.path), { recursive: !0 }), await a.symlink(e.target, e.path, e.type)) : e instanceof y && (await a.mkdir(c.dirname(e.path), { recursive: !0 }), await a.writeFile(e.path, e.content));
}));
}
}
return new P(i);
}, "createFixture");
//#endregion
export { k };
//# sourceMappingURL=dist-TTmWmO-C.js.map