Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb074672

Browse files
authored
Merge pull request#421 from coderoad/reset-commands
support multiple reset commands
2 parentsada2f6a +fc38477 commitb074672

File tree

6 files changed

+16
-8
lines changed

6 files changed

+16
-8
lines changed

‎src/actions/onRunReset.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as TT from 'typings/tutorial'
33
importContextfrom'../services/context/context'
44
import{exec}from'../services/node'
55
importresetfrom'../services/reset'
6+
import*ashooksfrom'../services/hooks'
67
importgetCommitHashByPositionfrom'../services/reset/lastHash'
78

89
typeResetAction={
@@ -30,8 +31,9 @@ const onRunReset = async (action: ResetAction, context: Context): Promise<void>
3031
reset({ branch, hash})
3132

3233
// if tutorial.config.reset.command, run it
33-
if(tutorial?.config?.reset?.command){
34-
awaitexec({command:tutorial.config.reset.command})
34+
constresetActions=tutorial?.config?.reset
35+
if(resetActions){
36+
hooks.onReset({commands:resetActions?.commands,vscodeCommands:resetActions?.vscodeCommands})
3537
}
3638
}
3739

‎src/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import * as TT from 'typings/tutorial'
33
import*asvscodefrom'vscode'
44
importcreateTestRunnerfrom'./services/testRunner'
55
importcreateWebViewfrom'./services/webview'
6-
importloggerfrom'./services/logger'
76
import*ashooksfrom'./services/hooks'
7+
importloggerfrom'./services/logger'
88

99
exportconstCOMMANDS={
1010
START:'coderoad.start',

‎src/services/hooks/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ export const onSolutionEnter = async (actions: TT.StepActions): Promise<void> =>
3838
awaitonRunTest()
3939
}
4040

41+
exportconstonReset=async(actions:TT.StepActions):Promise<void>=>{
42+
awaitrunCommands(actions?.commands)
43+
awaitrunVSCodeCommands(actions?.vscodeCommands)
44+
}
45+
4146
exportconstonError=async(error:Error):Promise<void>=>{
4247
telemetryOnError(error)
4348
}

‎src/services/hooks/utils/loadCommits.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import*asgitfrom'../../git'
22

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

‎src/services/reset/lastHash.ts

Lines changed: 1 addition & 1 deletion
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
thrownewError(`No step found matching${stepId}`)
4343
}
44-
constcommits=step.setup.commits
44+
constcommits=step.setup?.commits||[]
4545
if(!commits.length){
4646
thrownewError(`No commits found on step${stepId}`)
4747
}

‎typings/tutorial.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { ProgressStatus } from './index'
33
exporttypeMaybe<T>=T|null
44

55
exporttypeConfigReset={
6-
command?:string
6+
commands?:string[]
7+
vscodeCommands?:VSCodeCommand[]
78
}
89

910
exporttypeTutorialConfig={
@@ -57,7 +58,7 @@ export type TutorialSummary = {
5758

5859
exporttypeStepActions={
5960
commands?:string[]
60-
commits:string[]
61+
commits?:string[]
6162
files?:string[]
6263
watchers?:string[]
6364
filter?:string

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp