<commit_before>import { TaskResult, setResult } from 'vsts-task-lib/task';
import { WebApi } from 'vso-node-api/WebApi';
import { BuildWorker } from './queue-build.worker';
import { VstsApi } from './vsts-api';
import { EnvironmentConfiguration } from './configuration';
import { TaskSummary } from './util/task-summary';

function sleep(ms): Promise<{}> {
    return new Promise(resolve => setTimeout(resolve, ms));
}

async function run() {

    let builds = new Array<BuildWorker>();
    let configuration: EnvironmentConfiguration;
    try {
        // Get environment variables
        configuration = new EnvironmentConfiguration();

        // Get Vsts Build Api
        let api = new VstsApi(configuration);
        let buildApi = api.getBuildApi();

        // Start builds
        for (let i = 0; i < configuration.buildConfigurations.length; i++) {
            let worker = new BuildWorker(configuration.buildConfigurations[i], configuration, buildApi);
            builds.push(worker);
            await worker.queueBuild();
        }

        // Complete task if async is true
        if (configuration.async === true) {
            TaskSummary.attach(builds, configuration);
            setResult(TaskResult.Succeeded, `Build(s) queued (async).`);
            return;
        }

        // Poll build result
        let hasUnfinishedTasks;
        do {
            await sleep(2000);
            hasUnfinishedTasks = false;
            for (let i = 0; i < builds.length; i++) {
                if (!(await builds[i].getCompletedStatus())) {
                    hasUnfinishedTasks = true;
                }
            }
        } while (hasUnfinishedTasks);

        // Finish task
        TaskSummary.attach(builds, configuration);

        // Check build status
        for (let i = 0; i < builds.length; i++) {
            if (builds[i].getSuccessStatus() === false) {
                // At least one build failed
                setResult(TaskResult.Failed, `Queue build(s) faild`);
                return;
            }
        }

        // All builds successfully completed
        setResult(TaskResult.Succeeded, `Queue build(s) finished successfully`);
    }
    catch (error) {
        console.error(error);
        TaskSummary.attach(builds, configuration);
        setResult(TaskResult.Failed, `Queue build(s) faild`);
    }
}

run();
<commit_msg>Fixed typo in task result message<commit_after>import { TaskResult, setResult } from 'vsts-task-lib/task';
import { WebApi } from 'vso-node-api/WebApi';
import { BuildWorker } from './queue-build.worker';
import { VstsApi } from './vsts-api';
import { EnvironmentConfiguration } from './configuration';
import { TaskSummary } from './util/task-summary';

function sleep(ms): Promise<{}> {
    return new Promise(resolve => setTimeout(resolve, ms));
}

async function run() {

    let builds = new Array<BuildWorker>();
    let configuration: EnvironmentConfiguration;
    try {
        // Get environment variables
        configuration = new EnvironmentConfiguration();

        // Get Vsts Build Api
        let api = new VstsApi(configuration);
        let buildApi = api.getBuildApi();

        // Start builds
        for (let i = 0; i < configuration.buildConfigurations.length; i++) {
            let worker = new BuildWorker(configuration.buildConfigurations[i], configuration, buildApi);
            builds.push(worker);
            await worker.queueBuild();
        }

        // Complete task if async is true
        if (configuration.async === true) {
            TaskSummary.attach(builds, configuration);
            setResult(TaskResult.Succeeded, `Build(s) queued (async).`);
            return;
        }

        // Poll build result
        let hasUnfinishedTasks;
        do {
            await sleep(2000);
            hasUnfinishedTasks = false;
            for (let i = 0; i < builds.length; i++) {
                if (!(await builds[i].getCompletedStatus())) {
                    hasUnfinishedTasks = true;
                }
            }
        } while (hasUnfinishedTasks);

        // Finish task
        TaskSummary.attach(builds, configuration);

        // Check build status
        for (let i = 0; i < builds.length; i++) {
            if (builds[i].getSuccessStatus() === false) {
                // At least one build failed
                setResult(TaskResult.Failed, `Queue build(s) failed`);
                return;
            }
        }

        // All builds successfully completed
        setResult(TaskResult.Succeeded, `Queue build(s) finished successfully`);
    }
    catch (error) {
        console.error(error);
        TaskSummary.attach(builds, configuration);
        setResult(TaskResult.Failed, `Queue build(s) failed`);
    }
}

run();

{'fraction_non_alphanumeric': 0.11661073825503356, 'fraction_numerical': 0.002936241610738255, 'mean_word_length': 2.1088657105606257, 'pattern_counts': {'":': 0, '<': 13, '<?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': '639040', 'n_tokens_mistral': 1259, 'n_tokens_neox': 1234, 'n_words': 335}