ecstatic
Version:
A simple static file server middleware that works with both Express and Flatiron
23 lines (18 loc) • 393 B
JavaScript
;
module.exports = function permsToString(stat) {
if (!stat.isDirectory || !stat.mode) {
return '???!!!???';
}
const dir = stat.isDirectory() ? 'd' : '-';
const mode = stat.mode.toString(8);
return dir + mode.slice(-3).split('').map(n => [
'---',
'--x',
'-w-',
'-wx',
'r--',
'r-x',
'rw-',
'rwx',
][parseInt(n, 10)]).join('');
};