<commit_before>package de.iteratec.osm

import grails.boot.GrailsApp
import grails.util.Environment
import groovy.transform.CompileDynamic
import org.grails.io.watch.DirectoryWatcher
import org.grails.io.watch.FileExtensionFileChangeListener

import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.StandardCopyOption
import java.util.concurrent.ConcurrentLinkedQueue

class FrontendWatcher {

    private static DirectoryWatcher directoryWatcher

    static void initializeFrontendWatcher() {
        FrontendWatcher frontendWatcher = new FrontendWatcher()
        frontendWatcher.startFrontendWatcher(Environment.getCurrent())
    }

    @CompileDynamic
    protected void startFrontendWatcher(Environment environment) {

        String location = environment.getReloadLocation()

        def nodeExecLocation = new FileNameByRegexFinder().getFileNames( Paths.get(location, "build", "nodejs").toString(), "[\\\\/]([^\\\\/]*)[\\\\/]((node\\.exe+)|(bin/node))")[0]
        def nodeLocation = new File( nodeExecLocation ).getParent()

        if (location && nodeLocation) {

            Thread.start {
                def nodeModulesBin = Paths.get("${location}", "frontend", "node_modules", ".bin").toString()

                ProcessBuilder watchBuilder
                if( nodeExecLocation.endsWith(".exe") ) { // running on windows?
                    watchBuilder = new ProcessBuilder(["cmd", "/C", "ng build --watch"])
                            .redirectErrorStream(true).directory(new File(location, "frontend"))
                    watchBuilder.environment().put("PATH", "${nodeModulesBin};${nodeLocation};")
                }
                else {
                    watchBuilder = new ProcessBuilder(['sh', '-c', 'ng build --watch'])
                            .redirectErrorStream(true).directory(new File(location, "frontend"))
                    watchBuilder.environment().put("PATH", "${nodeModulesBin}:${nodeLocation}")<commit_msg>[IT-2501] Changes according to review<commit_after>package de.iteratec.osm

import grails.boot.GrailsApp
import grails.util.Environment
import groovy.transform.CompileDynamic
import org.grails.io.watch.DirectoryWatcher
import org.grails.io.watch.FileExtensionFileChangeListener

import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.StandardCopyOption
import java.util.concurrent.ConcurrentLinkedQueue

class FrontendWatcher {

    private static DirectoryWatcher directoryWatcher

    static void initializeFrontendWatcher() {
        FrontendWatcher frontendWatcher = new FrontendWatcher()
        frontendWatcher.startFrontendWatcher(Environment.getCurrent())
    }

    @CompileDynamic
    protected void startFrontendWatcher(Environment environment) {
        String location = environment.getReloadLocation()

        String nodeExecLocation = new FileNameByRegexFinder().getFileNames(Paths.get(location, "build", "nodejs").toString(), "([^\\/]*)((node\\.exe+)|(/bin/node(?!.)))")[0]
        def nodeLocation = new File(nodeExecLocation).getParent()

        if (location && nodeLocation) {
            Thread.start {
                def nodeModulesBin = Paths.get("${location}", "frontend", "node_modules", ".bin").toString()

                ProcessBuilder watchBuilder
                if( nodeExecLocation.endsWith(".exe") ) { // running on windows?
                    watchBuilder = new ProcessBuilder(["cmd", "/C", "ng build --watch"])
                            .redirectErrorStream(true).directory(new File(location, "frontend"))
                    watchBuilder.environment().put("PATH", "${nodeModulesBin};${nodeLocation}")
                }
                else {
                    watchBuilder = new ProcessBuilder(['sh', '-c', 'ng build --watch'])
                            .redirectErrorStream(true).directory(new File(location, "frontend"))
                    watchBuilder.environment().put("PATH", "${nodeModulesBin}:${nodeLocation}")
{'fraction_non_alphanumeric': 0.12577988520089842, 'fraction_numerical': 0.0014973795857249812, 'mean_word_length': 3.012012012012012, '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': '2271053', 'n_tokens_mistral': 1069, 'n_tokens_neox': 1020, 'n_words': 200}