You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// fix bug .length ===0 will be true if nothing provided, instead !filePath will return empty array which result true.
19
+
21
20
if(filePaths.length===0){
22
21
console.error("PLease provide a file path");
23
22
process.exit(1);
24
23
}
25
-
// loop trough the array to get each file path.
24
+
25
+
lettotalLines=0;
26
+
lettotalWords=0;
27
+
lettotalBytes=0;
28
+
lettotalChars=0;
29
+
26
30
filePaths.forEach((filePath)=>{
27
-
constcontent=fs.readFileSync(filePath,"utf-8");
28
-
29
-
constlines=content.split("\n").length-1;
30
-
constwords=content
31
-
.trim()
32
-
.split(/\s+/)
33
-
.filter((word)=>word!="").length;
34
-
// here I used Buffer.byteLength even if characters and bytes can be the same number .length, however sometimes an emoji or special characters can be heavier 2b or 4b
0 commit comments