1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 1× 2× 2× 2× 2× 1× 1× 1× 1× 2× 2× | /** * file-manager-js/info * @copyright 2018 Eyas Ranjous <eyas.ranjous@gmail.com> * @license MIT */ // gets an extended stats object from stats module.exports = (stat, dirSize) => (path) => { let info = {}; return stat(path) .then((stats) => { info = Object.assign({}, stats); if (stats.isFile()) { info.type = 'file'; return stats.size; } info.type = 'directory'; return dirSize(path); }) .then((sz) => { info.size = sz; return info; }); }; |