MCPcopy Create free account
hub / github.com/socketstream/socketstream / isDir

Function isDir

lib/utils/file.js:41–69  ·  view source on GitHub ↗

* Identifies if the path is directory * * @param {String} abspath Absolute path, should be already have replaced '\' with '/' to support Windows * @param {Object} found Object: {dirs: [], files: [] }, contains information about directory's files and subdirectories * @return {Object}

(abspath, found)

Source from the content-addressed store, hash-verified

39 * @return {Object} Updated 'found' object
40 */
41function isDir(abspath, found) {
42 var stat = fs.statSync(abspath),
43 abspathAry = abspath.split('/'),
44 data,
45 file_name;
46
47 if (!found) {
48 found = {dirs: [], files: [] }
49 }
50
51 if (stat.isDirectory() && !isHidden(abspathAry[abspathAry.length - 1])) {
52 found.dirs.push(abspath);
53
54 /* If we found a directory, recurse! */
55 data = exports.readDirSync(abspath);
56 found.dirs = found.dirs.concat(data.dirs);
57 found.files = found.files.concat(data.files);
58
59 } else {
60
61 abspathAry = abspath.split('/');
62 file_name = abspathAry[abspathAry.length - 1];
63
64 if (!isHidden(file_name)) {
65 found.files.push(abspath);
66 }
67 }
68 return found;
69}
70
71/**
72 * @ngdoc service

Callers 1

file.jsFile · 0.85

Calls 1

isHiddenFunction · 0.85

Tested by

no test coverage detected