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

Commit08d7820

Browse files
committed
allow for separate coderoad directory
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parente225806 commit08d7820

File tree

7 files changed

+33
-23
lines changed

7 files changed

+33
-23
lines changed

‎src/actions/utils/runCommands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const runCommands = async (commands: string[], send: (action: T.Action) => void)
1313
send({type:'COMMAND_START',payload:{process:{ ...process,status:'RUNNING'}}})
1414
letresult:{stdout:string;stderr:string}
1515
try{
16-
result=awaitexec(command)
16+
result=awaitexec({command})
1717
}catch(error){
1818
console.log(`Test failed:${error.message}`)
1919
send({type:'COMMAND_FAIL',payload:{process:{ ...process,status:'FAIL'}}})

‎src/editor/commands.ts

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

67
exportconstCOMMANDS={
@@ -47,7 +48,12 @@ export const createCommands = ({ extensionPath, workspaceState }: CreateCommandP
4748
// setup 1x1 horizontal layout
4849
webview.createOrShow()
4950
},
50-
[COMMANDS.CONFIG_TEST_RUNNER]:(config:TT.TutorialTestRunner)=>{
51+
[COMMANDS.CONFIG_TEST_RUNNER]:(config:TT.TutorialTestRunnerConfig)=>{
52+
if(config.actions){
53+
// setup tutorial test runner commits
54+
// assumes git already exists
55+
setupActions(config.actions,webview.send)
56+
}
5157
testRunner=createTestRunner(config,{
5258
onSuccess:(payload:Payload)=>{
5359
// send test pass message back to client

‎src/services/dependencies/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const semverRegex = /(?<=^v?|\sv?)(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)
55

66
exportconstversion=async(name:string):Promise<string|null>=>{
77
try{
8-
const{ stdout, stderr}=awaitexec(`${name} --version`)
8+
const{ stdout, stderr}=awaitexec({command:`${name} --version`})
99
if(!stderr){
1010
constmatch=stdout.match(semverRegex)
1111
if(match){

‎src/services/git/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const gitOrigin = 'coderoad'
66

77
conststashAllFiles=async():Promise<never|void>=>{
88
// stash files including untracked (eg. newly created file)
9-
const{ stdout, stderr}=awaitexec(`git stash --include-untracked`)
9+
const{ stdout, stderr}=awaitexec({command:`git stash --include-untracked`})
1010
if(stderr){
1111
console.error(stderr)
1212
thrownewError('Error stashing files')
@@ -21,7 +21,7 @@ const cherryPickCommit = async (commit: string, count = 0): Promise<never | void
2121
try{
2222
// cherry-pick pulls commits from another branch
2323
// -X theirs merges and accepts incoming changes over existing changes
24-
const{ stdout}=awaitexec(`git cherry-pick -X theirs${commit}`)
24+
const{ stdout}=awaitexec({command:`git cherry-pick -X theirs${commit}`})
2525
if(!stdout){
2626
thrownewError('No cherry-pick output')
2727
}
@@ -47,7 +47,7 @@ export function loadCommit(commit: string): Promise<never | void> {
4747
*/
4848

4949
exportasyncfunctionsaveCommit(message:string):Promise<never|void>{
50-
const{ stdout, stderr}=awaitexec(`git commit -am '${message}'`)
50+
const{ stdout, stderr}=awaitexec({command:`git commit -am '${message}'`})
5151
if(stderr){
5252
console.error(stderr)
5353
thrownewError('Error saving progress to Git')
@@ -58,7 +58,7 @@ export async function saveCommit(message: string): Promise<never | void> {
5858
exportasyncfunctionclear():Promise<Error|void>{
5959
try{
6060
// commit progress to git
61-
const{ stderr}=awaitexec('git reset HEAD --hard && git clean -fd')
61+
const{ stderr}=awaitexec({command:'git reset HEAD --hard && git clean -fd'})
6262
if(!stderr){
6363
return
6464
}
@@ -70,7 +70,7 @@ export async function clear(): Promise<Error | void> {
7070
}
7171

7272
asyncfunctioninit():Promise<Error|void>{
73-
const{ stderr}=awaitexec('git init')
73+
const{ stderr}=awaitexec({command:'git init'})
7474
if(stderr){
7575
thrownewError('Error initializing Git')
7676
}
@@ -85,13 +85,13 @@ export async function initIfNotExists(): Promise<never | void> {
8585

8686
exportasyncfunctioncheckRemoteConnects(repo:TT.TutorialRepo):Promise<never|void>{
8787
// check for git repo
88-
constexternalRepoExists=awaitexec(`git ls-remote --exit-code --heads${repo.uri}`)
88+
constexternalRepoExists=awaitexec({command:`git ls-remote --exit-code --heads${repo.uri}`})
8989
if(externalRepoExists.stderr){
9090
// no repo found or no internet connection
9191
thrownewError(externalRepoExists.stderr)
9292
}
9393
// check for git repo branch
94-
const{ stderr, stdout}=awaitexec(`git ls-remote --exit-code --heads${repo.uri}${repo.branch}`)
94+
const{ stderr, stdout}=awaitexec({command:`git ls-remote --exit-code --heads${repo.uri}${repo.branch}`})
9595
if(stderr){
9696
thrownewError(stderr)
9797
}
@@ -101,7 +101,7 @@ export async function checkRemoteConnects(repo: TT.TutorialRepo): Promise<never
101101
}
102102

103103
exportasyncfunctionaddRemote(repo:string):Promise<never|void>{
104-
const{ stderr}=awaitexec(`git remote add${gitOrigin}${repo} && git fetch${gitOrigin}`)
104+
const{ stderr}=awaitexec({command:`git remote add${gitOrigin}${repo} && git fetch${gitOrigin}`})
105105
if(stderr){
106106
constalreadyExists=stderr.match(`${gitOrigin} already exists.`)
107107
constsuccessfulNewBranch=stderr.match('new branch')
@@ -116,7 +116,7 @@ export async function addRemote(repo: string): Promise<never | void> {
116116

117117
exportasyncfunctioncheckRemoteExists():Promise<boolean>{
118118
try{
119-
const{ stdout, stderr}=awaitexec('git remote -v')
119+
const{ stdout, stderr}=awaitexec({command:'git remote -v'})
120120
if(stderr){
121121
returnfalse
122122
}

‎src/services/node/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ import { WORKSPACE_ROOT } from '../../environment'
66

77
constasyncExec=promisify(cpExec)
88

9-
exportconstexec=(cmd:string):Promise<{stdout:string;stderr:string}>|never=>{
10-
returnasyncExec(cmd,{
11-
cwd:WORKSPACE_ROOT,
9+
interfaceExecParams{
10+
command:string
11+
path?:string
12+
}
13+
14+
exportconstexec=(params:ExecParams):Promise<{stdout:string;stderr:string}>|never=>{
15+
returnasyncExec(params.command,{
16+
cwd:join(WORKSPACE_ROOT,params.path||''),
1217
})
1318
}
1419

‎src/services/testRunner/index.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import{TutorialTestRunnerConfig}from'typings/tutorial'
12
import{exec}from'../node'
23
importloggerfrom'../logger'
34
importparserfrom'./parser'
@@ -17,14 +18,10 @@ interface Callbacks {
1718
onError(payload:Payload):void
1819
}
1920

20-
interfaceTestRunnerConfig{
21-
command:string
22-
}
23-
2421
constfailChannelName='CodeRoad (Tests)'
2522
constlogChannelName='CodeRoad (Logs)'
2623

27-
constcreateTestRunner=(config:TestRunnerConfig,callbacks:Callbacks)=>{
24+
constcreateTestRunner=(config:TutorialTestRunnerConfig,callbacks:Callbacks)=>{
2825
returnasync(payload:Payload,onSuccess?:()=>void):Promise<void>=>{
2926
conststartTime=throttle()
3027
// throttle time early
@@ -39,7 +36,7 @@ const createTestRunner = (config: TestRunnerConfig, callbacks: Callbacks) => {
3936

4037
letresult:{stdout:string|undefined;stderr:string|undefined}
4138
try{
42-
result=awaitexec(config.command)
39+
result=awaitexec({command:config.command,path:config.path})
4340
}catch(err){
4441
result={stdout:err.stdout,stderr:err.stack}
4542
}

‎typings/tutorial.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export type Maybe<T> = T | null
22

33
exporttypeTutorialConfig={
44
appVersions:TutorialAppVersions
5-
testRunner:TutorialTestRunner
5+
testRunner:TutorialTestRunnerConfig
66
repo:TutorialRepo
77
dependencies?:TutorialDependency[]
88
}
@@ -51,8 +51,10 @@ export type StepActions = {
5151
watchers:string[]
5252
}
5353

54-
exportinterfaceTutorialTestRunner{
54+
exportinterfaceTutorialTestRunnerConfig{
5555
command:string
56+
path?:string
57+
actions?:StepActions
5658
}
5759

5860
exportinterfaceTutorialRepo{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp