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

support multiple reset commands#421

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 2 commits intomasterfromreset-commands
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
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
6 changes: 4 additions & 2 deletionssrc/actions/onRunReset.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@ import * as TT from 'typings/tutorial'
import Context from '../services/context/context'
import { exec } from '../services/node'
import reset from '../services/reset'
import * as hooks from '../services/hooks'
import getCommitHashByPosition from '../services/reset/lastHash'

type ResetAction = {
Expand DownExpand Up@@ -30,8 +31,9 @@ const onRunReset = async (action: ResetAction, context: Context): Promise<void>
reset({ branch, hash })

// if tutorial.config.reset.command, run it
if (tutorial?.config?.reset?.command) {
await exec({ command: tutorial.config.reset.command })
const resetActions = tutorial?.config?.reset
if (resetActions) {
hooks.onReset({ commands: resetActions?.commands, vscodeCommands: resetActions?.vscodeCommands })
}
}

Expand Down
2 changes: 1 addition & 1 deletionsrc/commands.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,8 +3,8 @@ import * as TT from 'typings/tutorial'
import * as vscode from 'vscode'
import createTestRunner from './services/testRunner'
import createWebView from './services/webview'
import logger from './services/logger'
import * as hooks from './services/hooks'
import logger from './services/logger'

export const COMMANDS = {
START: 'coderoad.start',
Expand Down
5 changes: 5 additions & 0 deletionssrc/services/hooks/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,6 +38,11 @@ export const onSolutionEnter = async (actions: TT.StepActions): Promise<void> =>
await onRunTest()
}

export const onReset = async (actions: TT.StepActions): Promise<void> => {
await runCommands(actions?.commands)
await runVSCodeCommands(actions?.vscodeCommands)
}

export const onError = async (error: Error): Promise<void> => {
telemetryOnError(error)
}
Expand Down
4 changes: 2 additions & 2 deletionssrc/services/hooks/utils/loadCommits.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import * as git from '../../git'

const loadCommits = async (commits: string[]): Promise<void> => {
if (commits) {
const loadCommits = async (commits: string[] = []): Promise<void> => {
if (commits && commits.length) {
// load the current list of commits for validation
for (const commit of commits) {
await git.loadCommit(commit)
Expand Down
2 changes: 1 addition & 1 deletionsrc/services/reset/lastHash.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,7 +41,7 @@ const getLastCommitHash = (position: T.Position, tutorial: TT.Tutorial | null):
if (!step) {
throw new Error(`No step found matching ${stepId}`)
}
const commits = step.setup.commits
const commits = step.setup?.commits || []
if (!commits.length) {
throw new Error(`No commits found on step ${stepId}`)
}
Expand Down
5 changes: 3 additions & 2 deletionstypings/tutorial.d.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,8 @@ import { ProgressStatus } from './index'
export type Maybe<T> = T | null

export type ConfigReset = {
command?: string
commands?: string[]
vscodeCommands?: VSCodeCommand[]
}

export type TutorialConfig = {
Expand DownExpand Up@@ -57,7 +58,7 @@ export type TutorialSummary = {

export type StepActions = {
commands?: string[]
commits: string[]
commits?: string[]
files?: string[]
watchers?: string[]
filter?: string
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp