Skip to content

Commit fc38477

Browse files
committed
allow vscode commands with reset
Signed-off-by: shmck <[email protected]>
1 parent d652457 commit fc38477

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

Diff for: src/actions/onRunReset.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@ const onRunReset = async (action: ResetAction, context: Context): Promise<void>
3030
// load timeline until last pass commit
3131
reset({ branch, hash })
3232

33-
// TODO: @deprecate command in favor of commands
3433
// if tutorial.config.reset.command, run it
35-
if (tutorial?.config?.reset?.command) {
36-
hooks.onReset([tutorial?.config?.reset?.command])
37-
} else if (tutorial?.config?.reset?.commands) {
38-
hooks.onReset(tutorial?.config?.reset?.commands)
34+
const resetActions = tutorial?.config?.reset
35+
if (resetActions) {
36+
hooks.onReset({ commands: resetActions?.commands, vscodeCommands: resetActions?.vscodeCommands })
3937
}
4038
}
4139

Diff for: src/services/hooks/index.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ export const onSolutionEnter = async (actions: TT.StepActions): Promise<void> =>
3838
await onRunTest()
3939
}
4040

41-
export const onReset = async (commands: string[]): Promise<void> => {
42-
await runCommands(commands)
41+
export const onReset = async (actions: TT.StepActions): Promise<void> => {
42+
await runCommands(actions?.commands)
43+
await runVSCodeCommands(actions?.vscodeCommands)
4344
}
4445

4546
export const onError = async (error: Error): Promise<void> => {

Diff for: src/services/hooks/utils/loadCommits.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as git from '../../git'
22

3-
const loadCommits = async (commits: string[]): Promise<void> => {
4-
if (commits) {
3+
const loadCommits = async (commits: string[] = []): Promise<void> => {
4+
if (commits && commits.length) {
55
// load the current list of commits for validation
66
for (const commit of commits) {
77
await git.loadCommit(commit)

Diff for: src/services/reset/lastHash.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const getLastCommitHash = (position: T.Position, tutorial: TT.Tutorial | null):
4141
if (!step) {
4242
throw new Error(`No step found matching ${stepId}`)
4343
}
44-
const commits = step.setup.commits
44+
const commits = step.setup?.commits || []
4545
if (!commits.length) {
4646
throw new Error(`No commits found on step ${stepId}`)
4747
}

Diff for: typings/tutorial.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { ProgressStatus } from './index'
33
export type Maybe<T> = T | null
44

55
export type ConfigReset = {
6-
command?: string
76
commands?: string[]
7+
vscodeCommands?: VSCodeCommand[]
88
}
99

1010
export type TutorialConfig = {
@@ -58,7 +58,7 @@ export type TutorialSummary = {
5858

5959
export type StepActions = {
6060
commands?: string[]
61-
commits: string[]
61+
commits?: string[]
6262
files?: string[]
6363
watchers?: string[]
6464
filter?: string

0 commit comments

Comments
 (0)