made gitversion & gitreleasemanager extend dotnet-tool

This commit is contained in:
Artur Stolear
2020-02-08 15:40:50 +02:00
parent 1be05ba386
commit aba63c943d
16 changed files with 201 additions and 230 deletions

View File

@@ -8,15 +8,14 @@ import { TYPES, IExecResult, IBuildAgent } from "./common";
import { IVersionManager } from "./versionManager";
export interface IDotnetTool {
run(args: string[]): Promise<IExecResult>;
toolInstall(toolName: string, versionSpec: string, checkLatest: boolean, includePre: boolean): Promise<string>;
}
@injectable()
export class DotnetTool implements IDotnetTool {
private buildAgent: IBuildAgent;
private versionManager: IVersionManager;
protected buildAgent: IBuildAgent;
protected versionManager: IVersionManager;
private httpClient: http.HttpClient;
constructor(
@@ -28,8 +27,9 @@ export class DotnetTool implements IDotnetTool {
this.httpClient = new http.HttpClient("dotnet");
}
public run(args: string[]): Promise<IExecResult> {
return this.buildAgent.exec("dotnet", args);
public execute(cmd: string, args: string[]): Promise<IExecResult> {
console.log(`Command: ${cmd} ${args.join(' ')}`);
return this.buildAgent.exec(cmd, args);
}
public async toolInstall(toolName: string, versionSpec: string, checkLatest: boolean, includePre: boolean)
@@ -131,7 +131,7 @@ export class DotnetTool implements IDotnetTool {
args = args.concat(["--version", version]);
}
const result = await this.run(args);
const result = await this.execute("dotnet", args);
const status = result.code === 0 ? "success" : "failure";
const message = result.code === 0 ? result.stdout : result.stderr;

View File

@@ -2,12 +2,10 @@ import { Container } from "inversify";
import { IVersionManager, VersionManager } from "./versionManager";
import { TYPES, IBuildAgent } from "./common";
import { BuildAgent } from "../agent/mock/build-agent";
import { IDotnetTool, DotnetTool } from "./dotnet-tool";
const container = new Container();
container.bind<IVersionManager>(TYPES.IVersionManager).to(VersionManager);
container.bind<IBuildAgent>(TYPES.IBuildAgent).to(BuildAgent);
container.bind<IDotnetTool>(TYPES.IDotnetTool).to(DotnetTool);
export default container;