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

Commit73fbd92

Browse files
committed
run setup commands in path
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parenteaf27ff commit73fbd92

File tree

7 files changed

+39
-32
lines changed

7 files changed

+39
-32
lines changed

‎CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
7171
{
7272
"config": {
7373
"testRunner": {
74-
"command":"npm test",
74+
"command":"npm test",// runs in path location or root
7575
"path":"coderoad",
7676
"actions": {
7777
"commits": ["a974aea"],
78-
"commands": ["cd coderoad &&npm install"]
78+
"commands": ["npm install"]// runs in path location or root
7979
}
8080
},
8181
}

‎src/actions/setupActions.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,19 @@ import openFiles from './utils/openFiles'
66
importrunCommandsfrom'./utils/runCommands'
77
importonErrorfrom'../services/sentry/onError'
88

9-
constsetupActions=async(
10-
actions:TT.StepActions,
11-
send:(action:T.Action)=>void,// send messages to client
12-
):Promise<void>=>{
9+
asyncfunctionwait(ms:number){
10+
returnnewPromise((resolve)=>{
11+
setTimeout(resolve,ms)
12+
})
13+
}
14+
15+
interfaceSetupActions{
16+
actions:TT.StepActions
17+
send:(action:T.Action)=>void// send messages to client
18+
path?:string
19+
}
20+
21+
exportconstsetupActions=async({ actions, send, path}:SetupActions):Promise<void>=>{
1322
const{ commands, commits, files, watchers}=actions
1423

1524
// 1. run commits
@@ -26,8 +35,13 @@ const setupActions = async (
2635
// 3. start file watchers
2736
loadWatchers(watchers||[])
2837

38+
awaitwait(1000)
39+
2940
// 4. run command
30-
awaitrunCommands(commands||[],send).catch(onError)
41+
awaitrunCommands({commands:commands||[], send, path}).catch(onError)
3142
}
3243

33-
exportdefaultsetupActions
44+
exportconstsolutionActions=async(params:SetupActions):Promise<void>=>{
45+
awaitgit.clear()
46+
returnsetupActions(params).catch(onError)
47+
}

‎src/actions/solutionActions.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

‎src/actions/utils/runCommands.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import*asTfrom'typings'
22
import{exec}from'../../services/node'
33

4-
construnCommands=async(commands:string[],send:(action:T.Action)=>void)=>{
4+
interfaceRunCommands{
5+
commands:string[]
6+
send:(action:T.Action)=>void
7+
path?:string
8+
}
9+
10+
construnCommands=async({ commands, send, path}:RunCommands)=>{
511
if(!commands.length){
612
return
713
}
@@ -13,7 +19,8 @@ const runCommands = async (commands: string[], send: (action: T.Action) => void)
1319
send({type:'COMMAND_START',payload:{process:{ ...process,status:'RUNNING'}}})
1420
letresult:{stdout:string;stderr:string}
1521
try{
16-
result=awaitexec({ command})
22+
result=awaitexec({ command, path})
23+
console.log(result)
1724
}catch(error){
1825
console.log(`Test failed:${error.message}`)
1926
send({type:'COMMAND_FAIL',payload:{process:{ ...process,status:'FAIL'}}})

‎src/channel/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import * as E from 'typings/error'
44
import*asvscodefrom'vscode'
55
import{satisfies}from'semver'
66
importsaveCommitfrom'../actions/saveCommit'
7-
importsetupActionsfrom'../actions/setupActions'
8-
importsolutionActionsfrom'../actions/solutionActions'
7+
import{setupActions,solutionActions}from'../actions/setupActions'
98
importtutorialConfigfrom'../actions/tutorialConfig'
109
import{COMMANDS}from'../editor/commands'
1110
importloggerfrom'../services/logger'
@@ -287,11 +286,11 @@ class Channel implements Channel {
287286
// load step actions (git commits, commands, open files)
288287
case'SETUP_ACTIONS':
289288
awaitvscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP,action.payload)
290-
setupActions(action.payload,this.send)
289+
setupActions({actions:action.payload,send:this.send})
291290
return
292291
// load solution step actions (git commits, commands, open files)
293292
case'SOLUTION_ACTIONS':
294-
awaitsolutionActions(action.payload,this.send)
293+
awaitsolutionActions({actions:action.payload,send:this.send})
295294
// run test following solution to update position
296295
vscode.commands.executeCommand(COMMANDS.RUN_TEST,action.payload)
297296
return

‎src/editor/commands.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import*asTTfrom'typings/tutorial'
22
import*asvscodefrom'vscode'
33
importcreateTestRunner,{Payload}from'../services/testRunner'
4-
importsetupActionsfrom'actions/setupActions'
4+
import{setupActions}from'../actions/setupActions'
55
importcreateWebViewfrom'../webview'
66

77
exportconstCOMMANDS={
@@ -48,11 +48,11 @@ export const createCommands = ({ extensionPath, workspaceState }: CreateCommandP
4848
// setup 1x1 horizontal layout
4949
webview.createOrShow()
5050
},
51-
[COMMANDS.CONFIG_TEST_RUNNER]:(config:TT.TutorialTestRunnerConfig)=>{
51+
[COMMANDS.CONFIG_TEST_RUNNER]:async(config:TT.TutorialTestRunnerConfig)=>{
5252
if(config.actions){
5353
// setup tutorial test runner commits
5454
// assumes git already exists
55-
setupActions(config.actions,webview.send)
55+
awaitsetupActions({actions:config.actions,send:webview.send,path:config.path})
5656
}
5757
testRunner=createTestRunner(config,{
5858
onSuccess:(payload:Payload)=>{

‎src/services/node/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ interface ExecParams {
1212
}
1313

1414
exportconstexec=(params:ExecParams):Promise<{stdout:string;stderr:string}>|never=>{
15-
returnasyncExec(params.command,{
16-
cwd:join(WORKSPACE_ROOT,params.path||''),
17-
})
15+
constcwd=join(WORKSPACE_ROOT,params.path||'')
16+
returnasyncExec(params.command,{ cwd})
1817
}
1918

2019
exportconstexists=(...paths:string[]):boolean|never=>{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp