Use the async shell exec
This commit is contained in:
+6
-4
@@ -68,8 +68,8 @@ async function hdparm(file) {
|
||||
}
|
||||
|
||||
async function getSwaps() {
|
||||
const stdout = safe.child_process.execSync('swapon --noheadings --raw --bytes --show=type,size,used,name', { encoding: 'utf8' });
|
||||
if (!stdout) return {};
|
||||
const [error, stdout] = await safe(shell.promises.exec('getSwaps', 'swapon --noheadings --raw --bytes --show=type,size,used,name', { encoding: 'utf8' }));
|
||||
if (error) return {};
|
||||
|
||||
const swaps = {};
|
||||
for (const line of stdout.trim().split('\n')) {
|
||||
@@ -329,8 +329,10 @@ async function getLogs(unit, options) {
|
||||
}
|
||||
|
||||
async function getBlockDevices() {
|
||||
const info = safe.JSON.parse(safe.child_process.execSync('lsblk --paths --json --list --fs', { encoding: 'utf8' }));
|
||||
if (!info) throw new BoxError(BoxError.INTERNAL_ERROR, safe.error.message);
|
||||
const [error, result] = await safe(shell.promises.exec('getBlockDevices', 'lsblk --paths --json --list --fs', { encoding: 'utf8' }));
|
||||
if (error) throw new BoxError(BoxError.INTERNAL_ERROR, `lsblk failed: ${error.message}`);
|
||||
const info = safe.JSON.parse(result);
|
||||
if (!info) throw new BoxError(BoxError.INTERNAL_ERROR, `failed to parse lsblk: ${safe.error.message}`);
|
||||
|
||||
const devices = info.blockdevices.filter(d => d.fstype === 'ext4' || d.fstype === 'xfs');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user