Forum

Count total lines o...
 
Notifications
Clear all

Count total lines of code in project (git) using PHP + Windows

1 Posty
1 Users
0 Reactions
636 Widok
0
Topic starter

powershell, cloc 

https://github.com/AlDanial/cloc

1 Answer
0
Topic starter
  1. download cloc.exe (for windows! any other app that was compiled  using MSYS2 may throw fatal error/Stack trace) and put in somewehere  
  2. example code
            $rawData = (shell_exec("powershell -ExecutionPolicy Bypass -Command \" ..\\tools\\cloc-1.94.exe ..\\resources\\js ..\\resources\\views  ..\\resources\\sass ..\\app ..\\routes ..\\config  | select-string 'SUM' | ForEach-Object { -split \$_ } \""));
            
            $splittedData = preg_split('/\r\n|\r|\n/', $rawData);
    
            $totalFiles = $splittedData[1];
            $totalLines = $splittedData[4];

Odpowiedź

Author Name

Author Email

Your question *

 
Preview 0 Revisions Saved
Share: