<commit_before>import * as fs from 'fs';
import * as path from 'path';
import * as vscode from 'vscode';

export var pluginStyles: string = readStyles().join("\n");

function readStyles(): string[] {
    let styles: string[] = [];
    vscode.extensions.all.map(
        (ext) => {
            let files: string[] = ext.packageJSON.contributes["markdown.previewStyles"];
            if (!files) return;
            files.map(f => {
                let fn = path.join(ext.extensionPath, f);
                if (!fs.existsSync(fn)) return;
                styles.push(`/* ${path.basename(f)} */\n` + fs.readFileSync(fn));
            });
        }, ""
    );
    return styles;
}<commit_msg>fix read previewStyles of undefined, solve #2<commit_after>import * as fs from 'fs';
import * as path from 'path';
import * as vscode from 'vscode';

export var pluginStyles: string = readStyles().join("\n");

function readStyles(): string[] {
    let styles: string[] = [];
    vscode.extensions.all.map(
        (ext) => {
            if (!ext || !ext.packageJSON || !ext.packageJSON.contributes) return;
            let files: string[] = ext.packageJSON.contributes["markdown.previewStyles"];
            if (!files) return;
            files.map(f => {
                let fn = path.join(ext.extensionPath, f);
                if (!fs.existsSync(fn)) return;
                styles.push(`/* ${path.basename(f)} */\n` + fs.readFileSync(fn));
            });
        }, ""
    );
    return styles;
}
{'fraction_non_alphanumeric': 0.1644295302013423, 'fraction_numerical': 0.0006711409395973154, 'mean_word_length': 2.2483660130718954, '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': '7351066', 'n_tokens_mistral': 447, 'n_tokens_neox': 446, 'n_words': 109}