Skip to content

Commit

Permalink
fix cli input file if empty
Browse files Browse the repository at this point in the history
  • Loading branch information
armados committed Jul 1, 2023
1 parent a3c767c commit 944f28d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions bin/glossa-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,14 @@ try {

var keyboardInput = null;
if (args["keyboard"]) {
try {


if (!fs.existsSync(args["keyboard"])) {
console.log("Σφάλμα. Το αρχείο που περιέχει τις τιμές εισόδου του προγράμματος δεν βρέθηκε.");
console.log("");
process.exit(1);
}

try {
const encoding = chardet.detectFileSync(args["keyboard"]);

keyboardInput = fs.readFileSync(args["keyboard"], {encoding: encoding}).toString();
Expand All @@ -87,9 +93,7 @@ if (args["keyboard"]) {
}

} catch (e) {
console.log("Σφάλμα. Το αρχείο που περιέχει τις τιμές εισόδου του προγράμματος δεν βρέθηκε.");
console.log("");
process.exit(1);
keyboardInput=null;
}
}

Expand Down

0 comments on commit 944f28d

Please sign in to comment.