@composio/core
Version:

49 lines (47 loc) • 1.36 kB
JavaScript
const require_chunk = require('../chunk-CQwRTUmo.cjs');
let node_fs = require("node:fs");
node_fs = require_chunk.__toESM(node_fs);
let node_os = require("node:os");
node_os = require_chunk.__toESM(node_os);
let node_path = require("node:path");
node_path = require_chunk.__toESM(node_path);
//#region src/platform/node.ts
/**
* Node.js platform implementation.
* Provides full file system and OS operations using Node.js built-in modules.
*/
const platform = {
supportsFileSystem: true,
homedir() {
try {
return node_os.homedir();
} catch {
return null;
}
},
joinPath(...paths) {
return node_path.join(...paths);
},
basename(filePath) {
return node_path.basename(filePath);
},
existsSync(filePath) {
return node_fs.existsSync(filePath);
},
mkdirSync(dirPath) {
node_fs.mkdirSync(dirPath, { recursive: true });
},
readFileSync(filePath, encoding) {
if (encoding === void 0) {
const buf = node_fs.readFileSync(filePath, { encoding: null });
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
}
return node_fs.readFileSync(filePath, { encoding });
},
writeFileSync(filePath, content, encoding) {
if (encoding && typeof content === "string") node_fs.writeFileSync(filePath, content, { encoding });
else node_fs.writeFileSync(filePath, content);
}
};
//#endregion
exports.platform = platform;