<commit_before>const config = require('../config.module')
const path = require('path');
import * as _ from "lodash";
const shell = require('shelljs');
const logger = require('./screen.module');
var properties = require("properties");
const Q = require('q');

export class Utils {

    public static getPropertiesFromNucleusPath(componentPath: string): string {
        let cleanpath = Utils.cleanPath(componentPath);
        return path.join(config.get('dynamoHome'), 'localconfig', cleanpath + '.properties');
    }

    public static getNucleusPathFromFilePath(filePath: string): string {
        return filePath.replace(/.*localconfig/, '').replace('.properties', '');
    }

    public static openFile(file: string): void {
        var exec = require('child_process').exec;
        var cmd = `${config.get('editor')} ${file}`;

        exec(cmd, function () {
            // command output is in stdout
        });
    }
    public static cleanPath(npath: string): string {
        if (_.isEmpty(npath)) {
            return '';
        } else {
            let res: string = npath.trim();
            res = res.replace('.properties', '');
            res = path.normalize(res)
            if (res.endsWith(path.sep)) {
                res = res.substr(0, res.length - 1);

            }
            return res;
        }
    }

    public static listLocalConfigFiles(): string[] {
        let dynHome = config.get('dynamoHome');
        let files = shell.find(dynHome).filter((val: string) => val.match(/\.properties$/));
        return files;
    }

    public static listLocalConfig(): string[] {
        let files = Utils.listLocalConfigFiles();
        let components = _.map(files, Utils.getNucleusPathFromFilePath).sort();
        return components;
    }

    public static printList(list: string[]): void {
        _.each(list, (elem: string) => {
            logger.out(elem);
        })
    }

    public static readConfigFile(filepath: string): Promise<any> {
        var deferred = Q.defer();
        properties.parse(filepath, { path: true }, function (error: any, obj: any) {
            if (error) {
                logger.error(error);
                deferred.reject(new Error(error));
            }
            else {<commit_msg>fix list local config path<commit_after>const config = require('../config.module')
const path = require('path');
import * as _ from "lodash";
const shell = require('shelljs');
const logger = require('./screen.module');
var properties = require("properties");
const Q = require('q');

export class Utils {

    public static getPropertiesFromNucleusPath(componentPath: string): string {
        let cleanpath = Utils.cleanPath(componentPath);
        return path.join(config.get('dynamoHome'), 'localconfig', cleanpath + '.properties');
    }

    public static getNucleusPathFromFilePath(filePath: string): string {
        return filePath.replace(/.*localconfig/, '').replace('.properties', '');
    }

    public static openFile(file: string): void {
        var exec = require('child_process').exec;
        var cmd = `${config.get('editor')} ${file}`;

        exec(cmd, function () {
            // command output is in stdout
        });
    }
    public static cleanPath(npath: string): string {
        if (_.isEmpty(npath)) {
            return '';
        } else {
            let res: string = npath.trim();
            res = res.replace('.properties', '');
            res = path.normalize(res)
            if (res.endsWith(path.sep)) {
                res = res.substr(0, res.length - 1);

            }
            return res;
        }
    }

    public static listLocalConfigFiles(): string[] {
        let dynHome = config.get('dynamoHome');
        let files = shell.find(path.join(dynHome,'localconfig')).filter((val: string) => val.match(/\.properties$/));
        return files;
    }

    public static listLocalConfig(): string[] {
        let files = Utils.listLocalConfigFiles();
        let components = _.map(files, Utils.getNucleusPathFromFilePath).sort();
        return components;
    }

    public static printList(list: string[]): void {
        _.each(list, (elem: string) => {
            logger.out(elem);
        })
    }

    public static readConfigFile(filepath: string): Promise<any> {
        var deferred = Q.defer();
        properties.parse(filepath, { path: true }, function (error: any, obj: any) {
            if (error) {
                logger.error(error);
                deferred.reject(new Error(error));
            }
            else {
{'fraction_non_alphanumeric': 0.14222809335094672, 'fraction_numerical': 0.0008806693086745927, 'mean_word_length': 2.3306451612903225, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '4523512', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1234, 'n_words': 300}