added methods has_module
and segment_number
This commit is contained in:
parent
4a61dfa4e2
commit
4ff5c00560
17
coretool.js
17
coretool.js
@ -1,6 +1,9 @@
|
||||
/* 基础小工具,可通用于服务端和用户端
|
||||
*/
|
||||
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
|
||||
module.exports = {
|
||||
BASEPORT_API_SERVER: 7000,
|
||||
BASEPORT_WEB_SERVER: 8000,
|
||||
@ -359,6 +362,18 @@ module.exports = {
|
||||
delete file.filename
|
||||
delete file.destination
|
||||
return file
|
||||
}
|
||||
},
|
||||
|
||||
has_module (module) {
|
||||
if (typeof (module) === 'string' && module) {
|
||||
return module.paths.some(modulesPath => fs.existsSync(path.join(modulesPath, module)))
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
segment_number (sizeBytes = '') { // segment a number with a space between each 3 digits
|
||||
return (sizeBytes).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ')
|
||||
},
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user