Created
November 18, 2018 19:20
-
-
Save hawkeye64/f29d008f22ceae0733dcb4fdb1af5baa to your computer and use it in GitHub Desktop.
getFolders and getFolderContents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getFolders: function (absolutePath) { | |
let folders = [] | |
// check incoming arg | |
if (!absolutePath || typeof absolutePath !== 'string') { | |
return folders | |
} | |
for (const fileInfo of walkFolders(absolutePath, false)) { | |
// all files and folders | |
if ('error' in fileInfo) { | |
console.error(`Error: ${fileInfo.rootDir} - ${fileInfo.error}`) | |
continue | |
} | |
// we only want folders | |
if (!fileInfo.isDir) { | |
continue | |
} | |
const node = this.createNode(fileInfo) | |
folders.push(node) | |
} | |
return folders | |
}, | |
getFolderContents: function (folder) { | |
let contents = [] | |
// check incoming arg | |
if (!folder || typeof folder !== 'string') { | |
return contents | |
} | |
for (const fileInfo of walkFolders(folder, false)) { | |
// all files and folders | |
if ('error' in fileInfo) { | |
console.error(`Error: ${fileInfo.rootDir} - ${fileInfo.error}`) | |
continue | |
} | |
const node = this.createNode(fileInfo) | |
contents.push(node) | |
} | |
return contents | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment