'NodeJS re-run a command in a row
My question is like, i have a command in 10th line and i am trying to rerun it in 30th line. How can i do this? The detail of rerun command is in the code.
Javascript;
import * as readline from 'node:readline/promises';
import { stdin as input, stdout as output } from 'node:process';
import * as fs from 'node:fs';
import moment from 'moment';
import * as process from 'node:process';
moment.locale("tr")
const saat = moment().format("DD MMMM dddd YYYY, HH:mm:ss");
const NotSaat = "["+saat+"]: "
const girdi = readline.createInterface({ input, output });
var GirisSorusu = await girdi.question("")
if(GirisSorusu.toLowerCase() == "hey therria" || "hey therria." || "hey therria!") {
const heyterya = await girdi.question("Terya: Buyrun efendim?\n")
if(heyterya.toLowerCase() == "not al" || "not al." || "not al!") {
const nots = await girdi.question("Therria: Ne almamı istersiniz?\n")
const NotRewrite = NotSaat + nots + "\n";
fs.open("notlar/notlar.txt", "a", (err, fd)=>{
if(err){
console.log("Dosyaya erimeye çalışırken bir hata oluştu: " + err);
}else{
fs.write(fd, NotRewrite, async(err, bytes)=>{
if(err){
console.log("Dosyaya yazmaya çalışırken bir hata oluştu: ");
}else{
const notaldim = await girdi.question("Therria: Notunuzu aldım, başka bir isteğiniz var mı?\n")
if(notaldim.toLowerCase == "yok" || "yok." || "yok!") {
await process.exit()
} else if (notaldim.toLowerCase == "evet" || "evet." || "evet!"); {
// Here is mine rerun command line, i want to rerun "heyterya" command
}
}
})
}
})
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|