<commit_before>import qbs
import qbs.File
import qbs.FileInfo
import qbs.ModUtils
import qbs.Process

Module {
    Depends { name: "nodejs" }

    additionalProductTypes: ["compiled_typescript"]

    property path toolchainInstallPath
    property string version: {
        var p = new Process();
        p.exec(compilerPath, ["--version"]);
        var match = p.readStdOut().match(/^Version ([0-9]+(\.[0-9]+){1,3})\n$/);
        if (match !== null)
            return match[1];
    }

    property var versionParts: version ? version.split('.').map(function(item) { return parseInt(item, 10); }) : []
    property int versionMajor: versionParts[0]
    property int versionMinor: versionParts[1]
    property int versionPatch: versionParts[2]
    property int versionBuild: versionParts[3]

    property string compilerName: "tsc"
    property string compilerPath: FileInfo.joinPaths(toolchainInstallPath, compilerName)

    property string warningLevel: "normal"<commit_msg>Typescript: Make version detection more robust.<commit_after>import qbs
import qbs.File
import qbs.FileInfo
import qbs.ModUtils
import qbs.Process

Module {
    Depends { name: "nodejs" }

    additionalProductTypes: ["compiled_typescript"]

    property path toolchainInstallPath
    property string version: {
        var p = new Process();
        p.exec(compilerPath, ["--version"]);
        var match = p.readStdOut().match(/.*\bVersion ([0-9]+(\.[0-9]+){1,3})\n$/);
        if (match !== null)
            return match[1];
    }

    property var versionParts: version ? version.split('.').map(function(item) { return parseInt(item, 10); }) : []
    property int versionMajor: versionParts[0]
    property int versionMinor: versionParts[1]
    property int versionPatch: versionParts[2]
    property int versionBuild: versionParts[3]

    property string compilerName: "tsc"
    property string compilerPath: FileInfo.joinPaths(toolchainInstallPath, compilerName)

    property string warningLevel: "normal"
{'fraction_non_alphanumeric': 0.1216691804927099, 'fraction_numerical': 0.013071895424836602, 'mean_word_length': 3.6823529411764704, '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': '6074176', 'n_tokens_mistral': 586, 'n_tokens_neox': 565, 'n_words': 152}