shell: make require take a tag
This commit is contained in:
+6
-6
@@ -33,7 +33,7 @@ const apps = require('./apps.js'),
|
||||
path = require('path'),
|
||||
paths = require('./paths.js'),
|
||||
safe = require('safetydance'),
|
||||
shell = require('./shell.js'),
|
||||
shell = require('./shell.js')('system'),
|
||||
tasks = require('./tasks.js'),
|
||||
volumes = require('./volumes.js');
|
||||
|
||||
@@ -44,7 +44,7 @@ const REBOOT_CMD = path.join(__dirname, 'scripts/reboot.sh');
|
||||
async function du(file) {
|
||||
assert.strictEqual(typeof file, 'string');
|
||||
|
||||
const [error, stdoutResult] = await safe(shell.promises.sudo('system', [ DU_CMD, file ], { captureStdout: true }));
|
||||
const [error, stdoutResult] = await safe(shell.promises.sudo([ DU_CMD, file ], { captureStdout: true }));
|
||||
if (error) throw new BoxError(BoxError.FS_ERROR, error);
|
||||
|
||||
return parseInt(stdoutResult.trim(), 10);
|
||||
@@ -53,7 +53,7 @@ async function du(file) {
|
||||
async function hdparm(file) {
|
||||
assert.strictEqual(typeof file, 'string');
|
||||
|
||||
const [error, stdoutResult] = await safe(shell.promises.sudo('system', [ HDPARM_CMD, file ], { captureStdout: true }));
|
||||
const [error, stdoutResult] = await safe(shell.promises.sudo([ HDPARM_CMD, file ], { captureStdout: true }));
|
||||
if (error) throw new BoxError(BoxError.FS_ERROR, error);
|
||||
|
||||
const lines = stdoutResult.split('\n');
|
||||
@@ -67,7 +67,7 @@ async function hdparm(file) {
|
||||
}
|
||||
|
||||
async function getSwaps() {
|
||||
const [error, stdout] = await safe(shell.exec('getSwaps', 'swapon --noheadings --raw --bytes --show=type,size,used,name', {}));
|
||||
const [error, stdout] = await safe(shell.exec('swapon --noheadings --raw --bytes --show=type,size,used,name', {}));
|
||||
if (error) return {};
|
||||
const output = stdout.trim();
|
||||
if (!output) return {}; // no swaps
|
||||
@@ -266,7 +266,7 @@ async function updateDiskUsage(progressCallback) {
|
||||
async function reboot() {
|
||||
await notifications.clearAlert(notifications.ALERT_REBOOT, 'Reboot Required');
|
||||
|
||||
const [error] = await safe(shell.promises.sudo('reboot', [ REBOOT_CMD ], {}));
|
||||
const [error] = await safe(shell.promises.sudo([ REBOOT_CMD ], {}));
|
||||
if (error) debug('reboot: could not reboot. %o', error);
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ async function getLogs(unit, options) {
|
||||
}
|
||||
|
||||
async function getBlockDevices() {
|
||||
const result = await shell.exec('getBlockDevices', 'lsblk --paths --json --list --fs --output +rota', {});
|
||||
const result = await shell.exec('lsblk --paths --json --list --fs --output +rota', {});
|
||||
const info = safe.JSON.parse(result);
|
||||
if (!info) throw new BoxError(BoxError.INTERNAL_ERROR, `failed to parse lsblk: ${safe.error.message}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user