Skip to content

Commit

Permalink
Fix issue 'vnstat not detected #1'
Browse files Browse the repository at this point in the history
  • Loading branch information
hulxv committed Jan 8, 2022
1 parent 952f77a commit 6d7594b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions main/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,21 @@ export function arrayOfObjectToCSV(data) {

export async function vnStatIsInstalled() {
let bash = `
if command -v vnstat &> /dev/null
then
echo "true"
else echo 'false'
fi
if ! [ -x "$(command -v vnstat)" ]; then
echo "false"
exit 1
else echo "true"
fi
`;

try {
const { stdout, stderr } = await exec(bash);
if (stderr) throw stderr;
return stdout.replace(/[\n, " "]/, "") == "true";
return stdout
.split("\n")
.map((e) => e.replace(/[\n, " "]/, ""))
.includes("true");
} catch (err) {
return err;
}
Expand Down

0 comments on commit 6d7594b

Please sign in to comment.