You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
610 B
33 lines
610 B
module.exports = getType |
|
|
|
function getType (st) { |
|
var types = [ |
|
'Directory', |
|
'File', |
|
'SymbolicLink', |
|
'Link', // special for hardlinks from tarballs |
|
'BlockDevice', |
|
'CharacterDevice', |
|
'FIFO', |
|
'Socket' |
|
] |
|
var type |
|
|
|
if (st.type && types.indexOf(st.type) !== -1) { |
|
st[st.type] = true |
|
return st.type |
|
} |
|
|
|
for (var i = 0, l = types.length; i < l; i++) { |
|
type = types[i] |
|
var is = st[type] || st['is' + type] |
|
if (typeof is === 'function') is = is.call(st) |
|
if (is) { |
|
st[type] = true |
|
st.type = type |
|
return type |
|
} |
|
} |
|
|
|
return null |
|
}
|
|
|