MCPcopy
hub / github.com/qawolf/cli / makeDefaultFs

Function makeDefaultFs

src/shell/fs.ts:57–127  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55};
56
57export function makeDefaultFs(): Fs {
58 return {
59 async mkdir(path, options) {
60 await fs.promises.mkdir(path, options);
61 },
62 pathExists,
63 readFile(path) {
64 return fs.promises.readFile(path, "utf-8");
65 },
66 async rm(path, options) {
67 await fs.promises.rm(path, options);
68 },
69 stat(path) {
70 return fs.promises.stat(path);
71 },
72 async unlink(path) {
73 await fs.promises.unlink(path);
74 },
75 async writeFile(path, data, options) {
76 if (typeof data === "string") {
77 await fs.promises.writeFile(path, data, {
78 encoding: "utf8",
79 mode: options?.mode,
80 });
81 } else {
82 await fs.promises.writeFile(path, data, options ?? undefined);
83 }
84 },
85 readdir(path) {
86 return fs.promises.readdir(path);
87 },
88 readdirWithTypes(path) {
89 // fs.promises.readdir returns Dirent[]; cast satisfies Fs's FsDirent[] return
90 return fs.promises.readdir(path, {
91 withFileTypes: true,
92 }) as Promise<FsDirent[]>;
93 },
94 rename(oldPath, newPath) {
95 return fs.promises.rename(oldPath, newPath);
96 },
97 utimes(path, atime, mtime) {
98 return fs.promises.utimes(path, atime, mtime);
99 },
100 createReadStream(path) {
101 // Pre-check so missing-file throws synchronously, matching makeMemoryFs contract
102 if (!fs.existsSync(path)) {
103 const err = Object.assign(
104 new Error(`ENOENT: no such file or directory, open '${path}'`),
105 { code: "ENOENT", errno: -2 },
106 );
107 throw err;
108 }
109 return fs.createReadStream(path);
110 },
111 async copyFile(source, destination) {
112 await fs.promises.copyFile(source, destination);
113 },
114 existsSync(path) {

Callers 15

resolveFromEnvDirFunction · 0.85
makeTestFsFunction · 0.85
createPlatformClientFunction · 0.85
fetchSignedUrlFunction · 0.85
writeTeamStorageAssetsFunction · 0.85
io.test.tsFile · 0.85
readManifestFunction · 0.85
writeManifestFunction · 0.85
hashFileFunction · 0.85
buildBaseContextFunction · 0.85
resolveDepsRootFunction · 0.85

Calls

no outgoing calls

Tested by 2

makeTestFsFunction · 0.68
makeCtxFunction · 0.68