MCPcopy Index your code
hub / github.com/acode/cli / writeFile

Function writeFile

cli/fileio.js:13–29  ·  view source on GitHub ↗
(directory, pathname, buffer, dirs)

Source from the content-addressed store, hash-verified

11const unusedFunctionDir = functionDir !== 'f' ? 'f' : 'functions';
12
13function writeFile(directory, pathname, buffer, dirs) {
14
15 pathname = path.join.apply(path, [].concat(directory.split('/'), pathname.split('/')));
16 let paths = pathname.split(path.sep);
17
18 for (let i = 1; i < paths.length; i++) {
19 let dirpath = path.join.apply(path, [process.cwd()].concat(paths.slice(0, i)));
20 if (!dirs[dirpath]) {
21 !fs.existsSync(dirpath) && fs.mkdirSync(dirpath);
22 dirs[dirpath] = true;
23 }
24 }
25
26 fs.writeFileSync(path.join(process.cwd(), pathname), buffer, {mode: 0o777});
27 return dirs;
28
29}
30
31function writeFiles(directory, files) {
32

Callers 1

writeFilesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected