function getTaskManifestPaths()

in BuildTasks/Common/Common.ts [512:543]


function getTaskManifestPaths(manifestPath: string, manifest: any): string[] {
    const tasks = getTaskPathContributions(manifest);
    const rootFolder = path.dirname(manifestPath);

    return tasks.reduce((result: string[], task: string) => {
        tl.debug(`Found task: ${task}`);
        const taskRoot: string = path.join(rootFolder, task);
        const rootManifest: string = path.join(taskRoot, "task.json");
        
        let localizationRoot = tl.filePathSupplied("localizationRoot") ? tl.getPathInput("localizationRoot", false) : taskRoot;
        if (localizationRoot) {
            localizationRoot = path.resolve(localizationRoot);
        }

        if (tl.exist(rootManifest)) {
            tl.debug(`Found single-task manifest: ${rootManifest}`);
            const rootManifests: string[] = [rootManifest];
            const rootLocManifest: string = path.join(localizationRoot, "task.loc.json");
            if (tl.exist(rootLocManifest)) {
                tl.debug(`Found localized single-task manifest: ${rootLocManifest}`);
                rootManifests.push(rootLocManifest);
            }
            return (result).concat(rootManifests);
        } else {
            const versionManifests = tl.findMatch(taskRoot, "*/task.json");
            const locVersionManifests = tl.findMatch(localizationRoot, "*/task.loc.json");
            tl.debug(`Found multi-task manifests: ${versionManifests.join(", ")}`);
            tl.debug(`Found multi-task localized manifests: ${locVersionManifests.join(", ")}`);
            return (result).concat(versionManifests).concat(locVersionManifests);
        }
    }, []);
}