diff --git a/app/utils/sendDeviceInfor.ts b/app/utils/sendDeviceInfor.ts
index 26d7c61..e592df4 100644
--- a/app/utils/sendDeviceInfor.ts
+++ b/app/utils/sendDeviceInfor.ts
@@ -1,4 +1,4 @@
-import Env from '@ioc:Adonis/Core/Env';
+import Env from "@ioc:Adonis/Core/Env";
import fs from "fs";
import moment from "moment/moment";
import dotenv from "dotenv";
@@ -17,7 +17,7 @@ export const sendDeviceInfora = async () => {
let html = "";
//List file today
const listFile = fs
- .readdirSync(Env.get('FOLDER_LOGS'))
+ .readdirSync(Env.get("FOLDER_LOGS"))
.filter((f) => f.includes("TEST01"));
//Configure mail
@@ -34,7 +34,7 @@ export const sendDeviceInfora = async () => {
//Read file in listFile
await listFile.map((file) => {
- fs.readFile(Env.get('FOLDER_LOGS') + "/" + file, "utf8", (err, data) => {
+ fs.readFile(Env.get("FOLDER_LOGS") + "/" + file, "utf8", (err, data) => {
if (err) {
console.log(`Error reading file: ${err}`);
} else {
@@ -123,16 +123,23 @@ export const sendDeviceInfora = async () => {
if (index > 0) {
if (PID !== "" && SN !== "") {
let RAM =
- (
- parseInt(
- showVersion
- .filter((line) => line.includes("bytes of memory"))
- .join("
")
- .match(regexMemory)[0]
- ) /
- 1024 /
- 1024
- ).toFixed(2) + "G";
+ showVersion
+ .filter((line) => line.includes("bytes of memory"))
+ .join("
")
+ .match(regexMemory) !== null
+ ? (
+ parseInt(
+ showVersion
+ .filter((line) =>
+ line.includes("bytes of memory")
+ )
+ .join("
")
+ .match(regexMemory)[0]
+ ) /
+ 1024 /
+ 1024
+ ).toFixed(2) + "G"
+ : "";
let flash = showVersion
.filter((line) =>
@@ -173,16 +180,23 @@ export const sendDeviceInfora = async () => {
} else {
if (PID !== "" && SN !== "") {
let RAM =
- (
- parseInt(
- showVersion
- .filter((line) => line.includes("bytes of memory"))
- .join("
")
- .match(regexMemory)[0]
- ) /
- 1024 /
- 1024
- ).toFixed(2) + "G";
+ showVersion
+ .filter((line) => line.includes("bytes of memory"))
+ .join("
")
+ .match(regexMemory) !== null
+ ? (
+ parseInt(
+ showVersion
+ .filter((line) =>
+ line.includes("bytes of memory")
+ )
+ .join("
")
+ .match(regexMemory)[0]
+ ) /
+ 1024 /
+ 1024
+ ).toFixed(2) + "G"
+ : "";
let flash = showVersion
.filter((line) =>
@@ -312,4 +326,4 @@ export const sendDeviceInfora = async () => {
} catch (error) {
console.log(error);
}
-}
+};