Skip to content

Refactor editor #396

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

Merged
merged 8 commits into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor setup/solution actions
Signed-off-by: shmck <[email protected]>
  • Loading branch information
ShMcK committed Jul 20, 2020
commit 0ec09029d1bf233469802a327abfe4ac46e774e1
1 change: 1 addition & 0 deletions src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export { default as onValidateSetup } from './onValidateSetup'
export { default as onRunReset } from './onRunReset'
export { default as onErrorPage } from './onErrorPage'
export { default as onTestPass } from './onTestPass'
export { onSetupActions, onSolutionActions } from './onActions'
6 changes: 3 additions & 3 deletions src/actions/setupActions.ts → src/actions/onActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface SetupActions {
dir?: string
}

export const setupActions = async ({ actions, send, dir }: SetupActions): Promise<void> => {
export const onSetupActions = async ({ actions, send, dir }: SetupActions): Promise<void> => {
if (!actions) {
return
}
Expand Down Expand Up @@ -49,7 +49,7 @@ export const setupActions = async ({ actions, send, dir }: SetupActions): Promis
}
}

export const solutionActions = async (params: SetupActions): Promise<void> => {
export const onSolutionActions = async (params: SetupActions): Promise<void> => {
await git.clear()
return setupActions(params).catch(onError)
return onSetupActions(params).catch(onError)
}
6 changes: 3 additions & 3 deletions src/channel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as T from 'typings'
import * as vscode from 'vscode'
import { setupActions, solutionActions } from './actions/setupActions'
import { setupActions, solutionActions } from './actions/onActions'
import { COMMANDS } from './commands'
import Context from './services/context/context'
import logger from './services/logger'
Expand Down Expand Up @@ -62,12 +62,12 @@ class Channel implements Channel {
// load step actions (git commits, commands, open files)
case 'SETUP_ACTIONS':
await vscode.commands.executeCommand(COMMANDS.SET_CURRENT_POSITION, action.payload.position)
setupActions({ actions: action.payload.actions, send: this.send })
actions.onSetupActions({ actions: action.payload.actions, send: this.send })
return
// load solution step actions (git commits, commands, open files)
case 'SOLUTION_ACTIONS':
await vscode.commands.executeCommand(COMMANDS.SET_CURRENT_POSITION, action.payload.position)
await solutionActions({ actions: action.payload.actions, send: this.send })
await actions.onSolutionActions({ actions: action.payload.actions, send: this.send })
// run test following solution to update position
vscode.commands.executeCommand(COMMANDS.RUN_TEST)
return
Expand Down
4 changes: 2 additions & 2 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as T from 'typings'
import * as TT from 'typings/tutorial'
import * as vscode from 'vscode'
import createTestRunner from './services/testRunner'
import { setupActions } from './actions/setupActions'
import { onSetupActions } from './actions/onActions'
import createWebView from './services/webview'
import logger from './services/logger'

Expand Down Expand Up @@ -57,7 +57,7 @@ export const createCommands = ({ extensionPath, workspaceState }: CreateCommandP
if (setup) {
// setup tutorial test runner commits
// assumes git already exists
await setupActions({
await onSetupActions({
actions: setup,
send: webview.send,
dir: testRunnerConfig.directory || testRunnerConfig.path,
Expand Down