distro info for linux
This commit is contained in:
parent
3247a3fcdf
commit
5db981228e
17
osUtil.js
Normal file
17
osUtil.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
const fs = require("fs");
|
||||
|
||||
const getLinuxDistroInfo = async() => {
|
||||
let os = await fs.promises.readFile('/etc/os-release', 'utf8')
|
||||
let opj = {}
|
||||
|
||||
os?.split('\n')?.forEach((line, index) => {
|
||||
let words = line?.split('=')
|
||||
let key = words[0]?.toLowerCase()
|
||||
if (key === '') return
|
||||
let value = words[1]?.replace(/"/g, '')
|
||||
opj[key] = value
|
||||
})
|
||||
return opj;
|
||||
}
|
||||
|
||||
module.exports = { getLinuxDistroInfo };
|
Loading…
Reference in New Issue
Block a user