UNPKG

approvals

Version:

Approval Tests Library - Capturing Human Intelligence

43 lines (42 loc) 1.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const GenericDiffReporterBase_1 = require("../GenericDiffReporterBase"); const AUtils_1 = require("../../AUtils"); const osTools_1 = require("../../osTools"); class VisualStudioReporter extends GenericDiffReporterBase_1.GenericDiffReporterBase { constructor() { super("VisualStudio"); if (osTools_1.platform.isWindows) { var edge = require("edge"); // Use edge to execute some .net and go find the installed version of visual studio. var getVisualStudioPath = edge.func(function () { /* async (input) => { // pulled this from https://github.com/approvals/ApprovalTests.Net/blob/master/ApprovalTests/Reporters/VisualStudioReporter.cs return (string)Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\devenv.exe", "", @"Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe"); } */ }); this.exePath = getVisualStudioPath(null, true); } } canReportOn(fileName) { if (osTools_1.platform.isWindows) { return super.canReportOn(fileName); } return false; } report(approved, received) { (0, AUtils_1.createEmptyFileIfNotExists)(approved); const ps = this.spawn(this.exePath, ["/diff", received, approved], { detached: true, }); ps.stdout.on("data", function (data) { console.log("reporter stdout: " + data); }); ps.stderr.on("data", function (data) { console.log("reporter stderr: " + data); }); } } exports.default = VisualStudioReporter;