This repository has been archived by the owner on Dec 12, 2022. It is now read-only.
forked from jest-community/vscode-jest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pick up jest 23.3 and enhance error reporting, troubleshooting etc
- Loading branch information
1 parent
9479c69
commit 475b901
Showing
11 changed files
with
374 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* collection of functions to show messages with actions in a consistent manner | ||
*/ | ||
|
||
import * as vscode from 'vscode' | ||
|
||
export interface MessageAction { | ||
title: string | ||
action: () => void | ||
} | ||
|
||
export function systemErrorMessage(message: string, ...actions: Array<MessageAction>) { | ||
const msg = vscode.window.showErrorMessage(message, ...extractActionTitles(actions)) | ||
if (msg) { | ||
msg.then(handleMessageActions(actions)) | ||
} | ||
} | ||
|
||
export function systemWarningMessage(message: string, ...actions: Array<MessageAction>) { | ||
const msg = vscode.window.showWarningMessage(message, ...extractActionTitles(actions)) | ||
if (msg) { | ||
msg.then(handleMessageActions(actions)) | ||
} | ||
} | ||
|
||
// common actions | ||
export const showTroubleshootingAction: MessageAction = { | ||
title: 'help', | ||
action: () => vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(TroubleShootingURL)), | ||
} | ||
|
||
export const TroubleShootingURL = 'https://github.com/jest-community/vscode-jest/blob/master/README.md#troubleshooting' | ||
// | ||
// internal methods | ||
// | ||
function extractActionTitles(actions?: Array<MessageAction>): string[] { | ||
if (!actions || actions.length === 0) { | ||
return [] | ||
} | ||
return actions.map(a => a.title) | ||
} | ||
function handleMessageActions(actions?: Array<MessageAction>): (action?: string) => void { | ||
return (action?: string) => { | ||
if (!action) { | ||
return | ||
} | ||
const found = actions.filter(a => a.title === action) | ||
if (found.length === 1) { | ||
found[0].action() | ||
} else { | ||
vscode.window.showWarningMessage(`unrecognized action ${action}`) | ||
} | ||
} | ||
} |
Oops, something went wrong.