Skip to content

Commit 769f7fa

Browse files
committed
refactor minor actions
Signed-off-by: shmck <[email protected]>
1 parent 9672565 commit 769f7fa

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

Diff for: src/actions/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ export { default as onTutorialContinueConfig } from './onTutorialContinueConfig'
44
export { default as onValidateSetup } from './onValidateSetup'
55
export { default as onRunReset } from './onRunReset'
66
export { default as onErrorPage } from './onErrorPage'
7-
export { default as onTestPass } from './onTestPass'
7+
export { onRunTest, onTestPass } from './onTest'
88
export { onSetupActions, onSolutionActions } from './onActions'
9+
export { onOpenLogs } from './onOpenLogs'

Diff for: src/actions/onOpenLogs.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import * as T from 'typings'
2+
import { showOutput } from '../services/testRunner/output'
3+
4+
export const onOpenLogs = async (action: T.Action) => {
5+
const channel = action.payload.channel
6+
await showOutput(channel)
7+
}
8+
9+
export default onOpenLogs

Diff for: src/actions/onTestPass.ts renamed to src/actions/onTest.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import * as git from '../services/git'
22
import * as T from 'typings'
3+
import * as vscode from 'vscode'
4+
import { COMMANDS } from '../commands'
35
import Context from '../services/context/context'
46

5-
const onTestPass = (action: T.Action, context: Context) => {
7+
export const onTestPass = (action: T.Action, context: Context) => {
68
const tutorial = context.tutorial.get()
79
if (!tutorial) {
810
throw new Error('Error with current tutorial. Tutorial may be missing an id.')
@@ -13,4 +15,6 @@ const onTestPass = (action: T.Action, context: Context) => {
1315
git.saveCommit('Save progress')
1416
}
1517

16-
export default onTestPass
18+
export const onRunTest = (action?: T.Action) => {
19+
vscode.commands.executeCommand(COMMANDS.RUN_TEST, action?.payload)
20+
}

Diff for: src/channel.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import * as T from 'typings'
22
import * as vscode from 'vscode'
3-
import { setupActions, solutionActions } from './actions/onActions'
43
import { COMMANDS } from './commands'
54
import Context from './services/context/context'
65
import logger from './services/logger'
76
import { openWorkspace } from './services/workspace'
8-
import { showOutput } from './services/testRunner/output'
97
import * as actions from './actions'
108

119
interface Channel {
@@ -69,18 +67,17 @@ class Channel implements Channel {
6967
await vscode.commands.executeCommand(COMMANDS.SET_CURRENT_POSITION, action.payload.position)
7068
await actions.onSolutionActions({ actions: action.payload.actions, send: this.send })
7169
// run test following solution to update position
72-
vscode.commands.executeCommand(COMMANDS.RUN_TEST)
70+
actions.onRunTest()
7371
return
7472
case 'EDITOR_SYNC_PROGRESS':
7573
// update progress when a level is deemed complete in the client
7674
await this.context.progress.syncProgress(action.payload.progress)
7775
return
7876
case 'EDITOR_OPEN_LOGS':
79-
const channel = action.payload.channel
80-
await showOutput(channel)
77+
actions.onOpenLogs(action)
8178
return
8279
case 'EDITOR_RUN_TEST':
83-
vscode.commands.executeCommand(COMMANDS.RUN_TEST, action?.payload)
80+
actions.onRunTest(action)
8481
return
8582
case 'EDITOR_RUN_RESET':
8683
actions.onRunReset(this.context)

0 commit comments

Comments
 (0)