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

Commitb7acb67

Browse files
committed
run setup commands
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent55c4dcb commitb7acb67

File tree

3 files changed

+53
-36
lines changed

3 files changed

+53
-36
lines changed

‎src/utils/cherryPick.ts

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

‎src/utils/exec.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import{execascpExec}from"child_process";
2+
import{promisify}from"util";
3+
4+
constasyncExec=promisify(cpExec);
5+
6+
exportfunctioncreateExec(cwd:string){
7+
returnfunctionexec(
8+
command:string
9+
):Promise<{stdout:string;stderr:string}>|never{
10+
returnasyncExec(command,{ cwd});
11+
};
12+
}
13+
14+
exportfunctioncreateCherryPick(cwd:string){
15+
returnasyncfunctioncherryPick(commits:string[]):Promise<void>{
16+
for(constcommitofcommits){
17+
try{
18+
const{ stdout}=awaitcreateExec(cwd)(
19+
`git cherry-pick -X theirs${commit}`
20+
);
21+
if(!stdout){
22+
console.warn(`No cherry-pick output for${commit}`);
23+
}
24+
}catch(e){
25+
console.warn(`Cherry-pick failed for${commit}`);
26+
}
27+
}
28+
};
29+
}
30+
31+
exportfunctioncreateCommandRunner(cwd:string){
32+
returnasyncfunctionrunCommands(commands:string[]){
33+
for(constcommandofcommands){
34+
try{
35+
console.log(`>${command}`);
36+
awaitcreateExec(cwd)(command);
37+
}catch(e){
38+
console.log(`Setup command failed: "${command}"`);
39+
console.log(e.message);
40+
}
41+
}
42+
};
43+
}

‎src/validate.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as fs from "fs-extra";
33
import*asyamlParserfrom"js-yaml";
44
import{getArg}from"./utils/args";
55
importgitP,{SimpleGit}from"simple-git/promise";
6-
import{gitPCherryPick}from"./utils/cherryPick";
6+
import{createCommandRunner,createCherryPick}from"./utils/exec";
77
import{getCommits,CommitLogObject}from"./utils/commits";
88

99
asyncfunctionvalidate(args:string[]){
@@ -23,8 +23,6 @@ async function validate(args: string[]) {
2323
try{
2424
skeleton=yamlParser.load(_yaml);
2525

26-
console.log("config",skeleton);
27-
// TODO: validate yaml
2826
if(!skeleton){
2927
thrownewError("Invalid yaml file contents");
3028
}
@@ -37,7 +35,6 @@ async function validate(args: string[]) {
3735

3836
// validate commits
3937
constcommits:CommitLogObject=awaitgetCommits({ localDir, codeBranch});
40-
console.log("commits",commits);
4138

4239
// setup tmp dir
4340
consttmpDir=path.join(localDir,".tmp");
@@ -48,17 +45,23 @@ async function validate(args: string[]) {
4845
}
4946
consttempGit:SimpleGit=gitP(tmpDir);
5047

51-
console.log(Object.keys(gitP));
52-
5348
awaittempGit.init();
5449
awaittempGit.addRemote("origin",skeleton.config.repo.uri);
5550
awaittempGit.fetch("origin",skeleton.config.repo.branch);
5651
// no js cherry pick implementation
57-
constcherryPick=gitPCherryPick(tmpDir);
52+
constcherryPick=createCherryPick(tmpDir);
53+
construnCommands=createCommandRunner(tmpDir);
5854

5955
// VALIDATE TUTORIAL TESTS
6056
if(commits.INIT){
57+
// load commits
58+
console.info("Loading setup commits...");
6159
cherryPick(commits.INIT);
60+
61+
// run commands
62+
if(skeleton.config?.testRunner?.setup?.commands){
63+
runCommands(skeleton.config?.testRunner?.setup?.commands);
64+
}
6265
}
6366

6467
// run test runner setup command(s)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp