From b8c250693e9f7807a4655cd04f6f688cc58721d5 Mon Sep 17 00:00:00 2001 From: Brian Cristante Date: Mon, 26 Mar 2018 09:37:10 -0400 Subject: [PATCH 1/5] Missed a couple commands. Catch unmocked commands at compile time. Bump patch version --- node/mock-answer.ts | 23 +++++++++++++++++++---- node/package.json | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/node/mock-answer.ts b/node/mock-answer.ts index 845fa78f6..094fe0ec1 100644 --- a/node/mock-answer.ts +++ b/node/mock-answer.ts @@ -1,5 +1,5 @@ -import path = require('path'); -import fs = require('fs'); +import * as path from 'path'; +import * as fs from 'fs'; export interface TaskLibAnswerExecResult { code: number, @@ -15,10 +15,25 @@ export interface TaskLibAnswers { find?: { [key: string]: string[] }, findMatch?: { [key: string]: string[] }, ls?: { [key: string]: string }, + osType?: { [key: string]: string }, rmRF?: { [key: string]: { success: boolean } }, - which?: { [key: string]: string; }, + stats?: { [key: string]: any }, // Can't use `fs.Stats` as most existing uses don't mock all required properties + which?: { [key: string]: string }, } +// TODO TypeScript 2.1: use `keyof` +export type MockedCommand = "checkPath" + | 'cwd' + | 'exec' + | 'exist' + | 'find' + | 'findMatch' + | 'ls' + | 'osType' + | 'rmRF' + | 'stats' + | 'which'; + export class MockAnswers { private _answers: TaskLibAnswers; @@ -29,7 +44,7 @@ export class MockAnswers { this._answers = answers; } - public getResponse(cmd: string, key: string, debug: (message: string) => void): any { + public getResponse(cmd: MockedCommand, key: string, debug: (message: string) => void): any { debug(`looking up mock answers for ${JSON.stringify(cmd)}, key '${JSON.stringify(key)}'`); if (!this._answers) { throw new Error('Must initialize'); diff --git a/node/package.json b/node/package.json index ba95efdd0..2b5eeaba8 100644 --- a/node/package.json +++ b/node/package.json @@ -1,6 +1,6 @@ { "name": "vsts-task-lib", - "version": "2.3.0", + "version": "2.3.1", "description": "VSTS Task SDK", "main": "./task.js", "typings": "./task.d.ts", From 53185b5dceb15f157e584efde0f32034bcd796b3 Mon Sep 17 00:00:00 2001 From: Brian Cristante Date: Mon, 26 Mar 2018 09:50:04 -0400 Subject: [PATCH 2/5] Need to bump again, had un-synced changes upstream --- node/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/package.json b/node/package.json index 8db285608..6a95086f0 100644 --- a/node/package.json +++ b/node/package.json @@ -1,6 +1,6 @@ { "name": "vsts-task-lib", - "version": "2.3.1", + "version": "2.3.2", "description": "VSTS Task SDK", "main": "./task.js", "typings": "./task.d.ts", From c80f45c64dd3ec77940907de2b9412b880062cb7 Mon Sep 17 00:00:00 2001 From: Brian Cristante Date: Mon, 26 Mar 2018 10:21:42 -0400 Subject: [PATCH 3/5] Strings should be single-quoted --- node/mock-answer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/mock-answer.ts b/node/mock-answer.ts index 094fe0ec1..5cdc6e77c 100644 --- a/node/mock-answer.ts +++ b/node/mock-answer.ts @@ -22,7 +22,7 @@ export interface TaskLibAnswers { } // TODO TypeScript 2.1: use `keyof` -export type MockedCommand = "checkPath" +export type MockedCommand = 'checkPath' | 'cwd' | 'exec' | 'exist' @@ -51,7 +51,7 @@ export class MockAnswers { } if (!this._answers[cmd]) { - debug(`no mock responses registered for given cmd`); + debug(`no mock responses registered for ${JSON.stringify(cmd)}`); return null; } From 5965041b28a63c41812064c98713d3aff27165b9 Mon Sep 17 00:00:00 2001 From: Brian Cristante Date: Mon, 26 Mar 2018 10:21:51 -0400 Subject: [PATCH 4/5] Bump minor version --- node/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/package.json b/node/package.json index 6a95086f0..3f3c7c697 100644 --- a/node/package.json +++ b/node/package.json @@ -1,6 +1,6 @@ { "name": "vsts-task-lib", - "version": "2.3.2", + "version": "2.4.0", "description": "VSTS Task SDK", "main": "./task.js", "typings": "./task.d.ts", From 11c14828abaa1d8c08f86ba7499b8f9a33ef61cf Mon Sep 17 00:00:00 2001 From: Brian Cristante Date: Mon, 26 Mar 2018 10:23:28 -0400 Subject: [PATCH 5/5] clarify TODO --- node/mock-answer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/mock-answer.ts b/node/mock-answer.ts index 5cdc6e77c..eabf703a6 100644 --- a/node/mock-answer.ts +++ b/node/mock-answer.ts @@ -21,7 +21,7 @@ export interface TaskLibAnswers { which?: { [key: string]: string }, } -// TODO TypeScript 2.1: use `keyof` +// TODO TypeScript 2.1: replace with `keyof TaskLibAnswers` export type MockedCommand = 'checkPath' | 'cwd' | 'exec'