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

Function readFiles

cli/fileio.js:46–65  ·  view source on GitHub ↗
(basepath, pathname, files, condenseDots)

Source from the content-addressed store, hash-verified

44}
45
46function readFiles(basepath, pathname, files, condenseDots) {
47 basepath = basepath || '.';
48 pathname = pathname || '.';
49 condenseDots = !!condenseDots;
50 return fs.readdirSync(path.join(basepath, pathname)).reduce((files, filename) => {
51 let savename = (condenseDots && filename.substr(0, 2) === '..') ?
52 filename.substr(1) :
53 filename;
54 let savepath = path.join(pathname, savename).split(path.sep).join('/');
55 let filepath = path.join(pathname, filename);
56 let fullpath = path.join(basepath, filepath);
57 if (fs.statSync(fullpath).isDirectory()) {
58 return readFiles(basepath, filepath, files, condenseDots);
59 } else {
60 files[savepath] = fs.readFileSync(fullpath);
61 return files;
62 }
63 }, files || {});
64
65};
66
67module.exports = {
68 readTemplateFiles: (directory) => readFiles(directory, '.', {}, true),

Callers 1

fileio.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected