I am creating an Electron app that helps me manage my disk space. However, I would like it to work on Linux/UNIX too.
I wrote the following code, which works great for Windows, but not Linux/UNIX systems.
window.onload = function(){
const cp = require('child_process')
cp.exec('wmic logicaldisk get size,freespace,caption', (error, stdout)=>{
let drives = stdout.trim()split('\r\r\n')
.map(value => value.trim().split(/\s{2,0}/))
.slice(1)
})
}
The output looks like this.
[
["560232439808", "C:", "999526756352", "System" ]
["999369699328", "D:", "999558213632", "SSD" ]
["1511570386944", "E:", "8001545039872", "Get" ]
["4620751712256", "F:", "8001545039872", "BR" ]
["788449492992", "G:", "4000650883072", "Seen" ]
["2296009408512", "H:", "4000768323584", "Seen 2" ]
["3594248679424", "I:", "8001545039872", "2160" ]
["3507750227968", "J:", "8001545039872", "1080" ]
["945300619264", "K:", "999625322496", "Trailer" ]
]
Since I am unfamiliar with Linux/UNIX, I am wondering how I can achieve the same output for Linux/UNIX too?