shell: make shell.sudo promise based and waitable
This commit is contained in:
+3
-3
@@ -45,7 +45,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([ DU_CMD, file ], { captureStdout: true }));
|
||||
const [error, stdoutResult] = await safe(shell.sudo([ DU_CMD, file ], { encoding: 'utf8' }));
|
||||
if (error) throw new BoxError(BoxError.FS_ERROR, error);
|
||||
|
||||
return parseInt(stdoutResult.trim(), 10);
|
||||
@@ -54,7 +54,7 @@ async function du(file) {
|
||||
async function hdparm(file) {
|
||||
assert.strictEqual(typeof file, 'string');
|
||||
|
||||
const [error, stdoutResult] = await safe(shell.promises.sudo([ HDPARM_CMD, file ], { captureStdout: true }));
|
||||
const [error, stdoutResult] = await safe(shell.sudo([ HDPARM_CMD, file ], { encoding: 'utf8' }));
|
||||
if (error) throw new BoxError(BoxError.FS_ERROR, error);
|
||||
|
||||
const lines = stdoutResult.split('\n');
|
||||
@@ -279,7 +279,7 @@ async function updateDiskUsage(progressCallback) {
|
||||
async function reboot() {
|
||||
await notifications.unpin(notifications.TYPE_REBOOT, {});
|
||||
|
||||
const [error] = await safe(shell.promises.sudo([ REBOOT_CMD ], {}));
|
||||
const [error] = await safe(shell.sudo([ REBOOT_CMD ], {}));
|
||||
if (error) debug('reboot: could not reboot. %o', error);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user