Skip to content

Feature/on reset #388

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 9 commits into from
Jul 12, 2020
Prev Previous commit
Next Next commit
trigger on reset command
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
  • Loading branch information
ShMcK committed Jul 12, 2020
commit 714879613ff586ea72b3469709f248cdac34d7cb
11 changes: 8 additions & 3 deletions src/channel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import saveCommit from '../actions/saveCommit'
import { setupActions, solutionActions } from '../actions/setupActions'
import tutorialConfig from '../actions/tutorialConfig'
import { COMMANDS } from '../editor/commands'
import logger from '../services/logger'
import Context from './context'
import { version, compareVersions } from '../services/dependencies'
import { openWorkspace, checkWorkspaceEmpty } from '../services/workspace'
import { readFile } from 'fs'
import { join } from 'path'
import { promisify } from 'util'
import logger from '../services/logger'
import { version, compareVersions } from '../services/dependencies'
import { openWorkspace, checkWorkspaceEmpty } from '../services/workspace'
import { showOutput } from '../services/testRunner/output'
import { exec } from '../services/node'
import { WORKSPACE_ROOT, TUTORIAL_URL } from '../environment'

const readFileAsync = promisify(readFile)
Expand Down Expand Up @@ -320,7 +321,11 @@ class Channel implements Channel {
vscode.commands.executeCommand(COMMANDS.RUN_TEST, action?.payload)
return
case 'EDITOR_RUN_RESET_SCRIPT':
const tutorial: TT.Tutorial | null = this.context.tutorial.get()
// if tutorial.config.reset.command, run it
if (tutorial?.config?.reset?.command) {
await exec({ command: tutorial.config.reset.command })
}
return
default:
logger(`No match for action type: ${actionType}`)
Expand Down
7 changes: 6 additions & 1 deletion typings/tutorial.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ import { ProgressStatus } from './index'

export type Maybe<T> = T | null

export type ConfigReset = {
command?: string
}

export type TutorialConfig = {
appVersions: TutorialAppVersions
appVersions?: TutorialAppVersions
testRunner: TestRunnerConfig
repo: TutorialRepo
dependencies?: TutorialDependency[]
reset?: ConfigReset
}

/** Logical groupings of tasks */
Expand Down