-
Notifications
You must be signed in to change notification settings - Fork 281
Missed a couple mocked commands. Bump patch version #334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b8c2506
17e5815
53185b5
c80f45c
5965041
11c1482
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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: replace with `keyof TaskLibAnswers` | ||
| export type MockedCommand = 'checkPath' | ||
| | 'cwd' | ||
| | 'exec' | ||
| | 'exist' | ||
| | 'find' | ||
| | 'findMatch' | ||
| | 'ls' | ||
| | 'osType' | ||
| | 'rmRF' | ||
| | 'stats' | ||
| | 'which'; | ||
|
|
||
| export class MockAnswers { | ||
| private _answers: TaskLibAnswers; | ||
|
|
||
|
|
@@ -29,14 +44,14 @@ 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 { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe MockCommand?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it's technically a breaking change if people are calling I said
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There might be 3rd party extensions using it
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we can bump the minor version |
||
| debug(`looking up mock answers for ${JSON.stringify(cmd)}, key '${JSON.stringify(key)}'`); | ||
| if (!this._answers) { | ||
| throw new Error('Must initialize'); | ||
| } | ||
|
|
||
| if (!this._answers[cmd]) { | ||
| debug(`no mock responses registered for given cmd`); | ||
| debug(`no mock responses registered for ${JSON.stringify(cmd)}`); | ||
| return null; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import ... requirehas slightly different semantics thanimport ... from. My understanding is thatrequireexecutes the module as the CommonJS and AMDrequirefunction does so that any side effects from the module are applied.import ... fromis the normal way to import a module in TypeScript.