<commit_before>package codenizer.sonarqube.typescript;

public class AnalysisRunnerImpl implements AnalysisRunner {    
    public AnalysisResult[] Execute(String projectRootDirectory) {
        AnalysisResult[] result = new AnalysisResult[0];
        
       try {
           // 1) Set working directory to projectRootDirectory
           // 2) Call analyzer.js
           // 3) Parse result file
           Process p = Runtime.getRuntime().exec("node analyzer.js");
           
           p.waitFor();           
       }
       catch(Exception ex) {
           
       }
    
        return result;
    }
}<commit_msg>Set working directory and command arguments<commit_after>package codenizer.sonarqube.typescript;

import java.io.File;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AnalysisRunnerImpl implements AnalysisRunner {    
    private final Logger log = LoggerFactory.getLogger(this.getClass());
    
    public AnalysisResult[] Execute(String projectRootDirectory) {
        AnalysisResult[] result = new AnalysisResult[0];
        
       try {
           // 1) Set working directory to projectRootDirectory
           // 2) Call analyzer.js
           // 3) Parse result file
           
           String[] commands = new String[] {
               "node",
               "analyzer.js",
               "**/*.ts"    /* we can specify this glob because we're already in the source directory */
           };
           
           Process p = Runtime.getRuntime().exec(commands, null /* inherit env */, new File(projectRootDirectory));
           
           int exitCode = p.waitFor();
           
           if(exitCode != 0) {
               log.error("Running analyzer failed with exit code " + exitCode);
           }
           
           // Look for file in current directory
           String pathToResultFile = "ts-analysis-results.json";
           
           result = AnalysisResultParser.FromFile(pathToResultFile);
       }
       catch(Exception ex) {
           log.error(ex.getMessage());
       }
    
        return result;
    }
}
{'fraction_non_alphanumeric': 0.08986615678776291, 'fraction_numerical': 0.005258126195028681, 'mean_word_length': 1.7906666666666666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7250823', 'n_tokens_mistral': 524, 'n_tokens_neox': 512, 'n_words': 138}