mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-04-29 12:10:24 +00:00
Initial commit of eigent-main
This commit is contained in:
commit
723df5a03e
1144 changed files with 103478 additions and 0 deletions
37
package/@stackframe/stack-shared/dist/esm/utils/fs.js
vendored
Normal file
37
package/@stackframe/stack-shared/dist/esm/utils/fs.js
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// src/utils/fs.tsx
|
||||
import * as stackFs from "fs";
|
||||
import * as path from "path";
|
||||
async function list(path2) {
|
||||
return await stackFs.promises.readdir(path2);
|
||||
}
|
||||
async function listRecursively(p, options = {}) {
|
||||
const files = await list(p);
|
||||
return [
|
||||
...(await Promise.all(files.map(async (fileName) => {
|
||||
const filePath = path.join(p, fileName);
|
||||
if ((await stackFs.promises.stat(filePath)).isDirectory()) {
|
||||
return [
|
||||
...await listRecursively(filePath, options),
|
||||
...options.excludeDirectories ? [] : [filePath]
|
||||
];
|
||||
} else {
|
||||
return [filePath];
|
||||
}
|
||||
}))).flat()
|
||||
];
|
||||
}
|
||||
function writeFileSyncIfChanged(path2, content) {
|
||||
if (stackFs.existsSync(path2)) {
|
||||
const existingContent = stackFs.readFileSync(path2, "utf-8");
|
||||
if (existingContent === content) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
stackFs.writeFileSync(path2, content);
|
||||
}
|
||||
export {
|
||||
list,
|
||||
listRecursively,
|
||||
writeFileSyncIfChanged
|
||||
};
|
||||
//# sourceMappingURL=fs.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue