Created
November 18, 2018 19:21
-
-
Save hawkeye64/884ac1fca3af81dfc0b926379b4f1f54 to your computer and use it in GitHub Desktop.
createNode function
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
createNode: function (fileInfo) { | |
let nodeKey = fileInfo.rootDir | |
if (nodeKey.charAt(nodeKey.length - 1) !== path.sep) { | |
nodeKey += path.sep | |
} | |
if (fileInfo.fileName === path.sep) { | |
fileInfo.fileName = nodeKey | |
} | |
else { | |
nodeKey += fileInfo.fileName | |
} | |
// get file mime type | |
const mimeType = mime.lookup(nodeKey) | |
// create object | |
return { | |
label: fileInfo.fileName, | |
nodeKey: nodeKey, | |
expandable: fileInfo.isDir, | |
tickable: true, | |
lazy: true, | |
children: [], | |
data: { | |
rootDir: fileInfo.rootDir, | |
isDir: fileInfo.isDir, | |
mimeType: mimeType, | |
stat: fileInfo.stat | |
} | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment