<commit_before>'use strict';
import * as fs from 'fs';
import * as path from 'path';

export const LOCAL_SETTINGS: string = 'local-settings.json';

export class LocalSettings {
    private codeSyncExtensionDir: string;

    constructor(codeSyncExtensionDir: string) {
        this.codeSyncExtensionDir = codeSyncExtensionDir;
    }

    import(externalSettingsPath: string, internalSettingsPath: string): void {
        let localSettingsPath: string = path.join(this.codeSyncExtensionDir, LOCAL_SETTINGS);
        let settings: any = JSON.parse(fs.readFileSync(externalSettingsPath, 'utf8'));
        if (fs.existsSync(localSettingsPath)) {
            let localSettings: any = JSON.parse(fs.readFileSync(localSettingsPath, 'utf8'));
            let localSettingsKeys: string[] = Object.keys(localSettings);
            localSettingsKeys.forEach(key => {
                settings[key] = localSettings[key];
            });
        }
        fs.writeFileSync(internalSettingsPath, JSON.stringify(settings, null, 4));
    }

    export(internalSettingsPath: string, externalSettingsPath: string): void {
        let localSettingsPath: string = path.join(this.codeSyncExtensionDir, LOCAL_SETTINGS);
        let settings: any = JSON.parse(fs.readFileSync(internalSettingsPath, 'utf8'));
        if (!fs.existsSync(localSettingsPath)) {
            fs.writeFileSync(localSettingsPath, JSON.stringify({}, null, 4));
        }
        if (fs.existsSync(localSettingsPath)) {
            let localSettings: any = JSON.parse(fs.readFileSync(localSettingsPath, 'utf8'));
            let localSettingsKeys: string[] = Object.keys(localSettings);
            localSettingsKeys.forEach(key => {
                delete settings[key];
            });
        }
        fs.writeFileSync(externalSettingsPath, JSON.stringify(settings, null, 4));
    }
}<commit_msg>Support comments in VSCode settings and local-settings files<commit_after>'use strict';
import * as fs from 'fs';
import * as path from 'path';
import * as helpers from './helpers';

export const LOCAL_SETTINGS: string = 'local-settings.json';

export class LocalSettings {
    private codeSyncExtensionDir: string;

    constructor(codeSyncExtensionDir: string) {
        this.codeSyncExtensionDir = codeSyncExtensionDir;
    }

    import(externalSettingsPath: string, internalSettingsPath: string): void {
        let localSettingsPath: string = path.join(this.codeSyncExtensionDir, LOCAL_SETTINGS);
        let settings: any = helpers.parseJson(fs.readFileSync(externalSettingsPath, 'utf8'));
        if (fs.existsSync(localSettingsPath)) {
            let localSettings: any = helpers.parseJson(fs.readFileSync(localSettingsPath, 'utf8'));
            let localSettingsKeys: string[] = Object.keys(localSettings);
            localSettingsKeys.forEach(key => {
                settings[key] = localSettings[key];
            });
        }
        fs.writeFileSync(internalSettingsPath, helpers.stringifyJson(settings));
    }

    export(internalSettingsPath: string, externalSettingsPath: string): void {
        let localSettingsPath: string = path.join(this.codeSyncExtensionDir, LOCAL_SETTINGS);
        let settings: any = helpers.parseJson(fs.readFileSync(internalSettingsPath, 'utf8'));
        if (!fs.existsSync(localSettingsPath)) {
            fs.writeFileSync(localSettingsPath, helpers.stringifyJson({}));
        }
        if (fs.existsSync(localSettingsPath)) {
            let localSettings: any = JSON.parse(fs.readFileSync(localSettingsPath, 'utf8'));
            let localSettingsKeys: string[] = Object.keys(localSettings);
            localSettingsKeys.forEach(key => {
                delete settings[key];
            });
        }
        fs.writeFileSync(externalSettingsPath, helpers.stringifyJson(settings));
    }
}
{'fraction_non_alphanumeric': 0.10985247629083246, 'fraction_numerical': 0.002897787144362487, 'mean_word_length': 3.300113250283126, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '772449', 'n_tokens_mistral': 1014, 'n_tokens_neox': 1006, 'n_words': 204}