Skip to content

Conversation

@brcrista
Copy link
Contributor

Forgot to bump the patch version before.
Noticed that I missed a couple of commands that were actually mocked, and so the previous changes were insufficient to stop coercing the TaskLibAnswer type in our existing code. I defined the MockedCommand type here so that the compiler will catch all arguments to getResponse.

@@ -1,5 +1,5 @@
import path = require('path');
import fs = require('fs');
import * as path from 'path';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import ... require has slightly different semantics than import ... from. My understanding is that require executes the module as the CommonJS and AMD require function does so that any side effects from the module are applied. import ... from is the normal way to import a module in TypeScript.

which?: { [key: string]: string },
}

// TODO TypeScript 2.1: use `keyof`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we're using version 1.8.7 of the TypeScript compiler. TypeScript 2.1 adds a keyof operator: you can just say keyof TaskLibAnswer instead of defining MockedCommand.

}

// TODO TypeScript 2.1: use `keyof`
export type MockedCommand = "checkPath"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double quotes here and single below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, will fix

}

public getResponse(cmd: string, key: string, debug: (message: string) => void): any {
public getResponse(cmd: MockedCommand, key: string, debug: (message: string) => void): any {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change? May want to bump at least the minor since it's mock and not the main code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe MockCommand?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's technically a breaking change if people are calling getResponse directly for some reason. There aren't any uses right now in vsts-tasks -- it's just used internally in mock-task and mock-toolrunner.

I said MockedCommand since it's "one of the commands that are mocked" and not the mock itself.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be 3rd party extensions using it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we can bump the minor version

@stephenmichaelf
Copy link
Member

LGTM.

One last thing:

@bryanmacfarlane Can you confirm that bumping minor version is sufficient when making a breaking change? Don't mean to be pedantic but want to make sure we are staying consistent with the versioning for this lib. Especially given what @madhurig helpfully mentioned about 3rd party extensions.

@bryanmacfarlane
Copy link
Contributor

fine.

@bryanmacfarlane bryanmacfarlane merged commit d3b2d15 into microsoft:master Apr 2, 2018
fullstackinfo pushed a commit to fullstackinfo/azure-pipelines-task-lib that referenced this pull request Aug 17, 2024
* Missed a couple commands.  Catch unmocked commands at compile time.  Bump patch version

* Need to bump again, had un-synced changes upstream

* Strings should be single-quoted

* Bump minor version

* clarify TODO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants