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

Commit1861195

Browse files
authored
Merge pull request#34 from coderoad/feature/validate
Feature/validate
2 parents46b64db +2fc1113 commit1861195

File tree

6 files changed

+263
-42
lines changed

6 files changed

+263
-42
lines changed

‎package-lock.json

Lines changed: 41 additions & 3 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"dependencies": {
5050
"ajv":"^6.12.2",
5151
"esm":"^3.2.25",
52+
"fs-extra":"^9.0.1",
5253
"js-yaml":"^3.14.0",
5354
"kleur":"^3.0.3",
5455
"lodash":"^4.17.15",
@@ -58,6 +59,7 @@
5859
"devDependencies": {
5960
"@babel/preset-typescript":"^7.10.1",
6061
"@types/ajv":"^1.0.0",
62+
"@types/fs-extra":"^9.0.1",
6163
"@types/inquirer":"^6.5.0",
6264
"@types/jest":"^25.2.3",
6365
"@types/js-yaml":"^3.12.4",

‎src/utils/exec.ts

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import*asTfrom"../../typings/tutorial";
2+
import{execascpExec}from"child_process";
3+
import*aspathfrom"path";
4+
import{promisify}from"util";
5+
6+
constasyncExec=promisify(cpExec);
7+
8+
exportfunctioncreateExec(cwd:string){
9+
returnasyncfunctionexec(
10+
command:string
11+
):Promise<{stdout:string|null;stderr:string}>{
12+
try{
13+
constresult=awaitasyncExec(command,{ cwd});
14+
returnresult;
15+
}catch(e){
16+
return{stdout:null,stderr:e.message};
17+
}
18+
};
19+
}
20+
21+
exportfunctioncreateCherryPick(cwd:string){
22+
returnasyncfunctioncherryPick(commits:string[]):Promise<void>{
23+
for(constcommitofcommits){
24+
try{
25+
const{ stdout}=awaitcreateExec(cwd)(
26+
`git cherry-pick -X theirs${commit}`
27+
);
28+
if(!stdout){
29+
console.warn(`No cherry-pick output for${commit}`);
30+
}
31+
}catch(e){
32+
console.warn(`Cherry-pick failed for${commit}`);
33+
}
34+
}
35+
};
36+
}
37+
38+
exportfunctioncreateCommandRunner(cwd:string){
39+
returnasyncfunctionrunCommands(
40+
commands:string[],
41+
dir?:string
42+
):Promise<boolean>{
43+
leterrors=[];
44+
for(constcommandofcommands){
45+
try{
46+
console.log(`-->${command}`);
47+
letcwdDir=cwd;
48+
if(dir){
49+
cwdDir=path.join(cwd,dir);
50+
}
51+
const{ stdout, stderr}=awaitcreateExec(cwdDir)(command);
52+
53+
console.warn(stderr);
54+
}catch(e){
55+
console.error(`Command failed: "${command}"`);
56+
console.warn(e.message);
57+
errors.push(e.message);
58+
}
59+
}
60+
return!!errors.length;
61+
};
62+
}
63+
64+
// function isAbsolute(p: string) {
65+
// return path.normalize(p + "/") === path.normalize(path.resolve(p) + "/");
66+
// }
67+
68+
exportfunctioncreateTestRunner(cwd:string,config:T.TestRunnerConfig){
69+
const{ command, args, directory}=config;
70+
71+
// const commandIsAbsolute = isAbsolute(command);
72+
73+
letwd=cwd;
74+
if(directory){
75+
wd=path.join(cwd,directory);
76+
}
77+
78+
constcommandWithArgs=`${command}${args.tap}`;
79+
80+
returnasyncfunctionrunTest():Promise<{
81+
stdout:string|null;
82+
stderr:string|null;
83+
}>{
84+
try{
85+
// console.log(await createExec(wd)("ls -a node_modules/.bin"));
86+
returnawaitcreateExec(wd)(commandWithArgs);
87+
}catch(e){
88+
returnPromise.resolve({stdout:null,stderr:e.message});
89+
}
90+
};
91+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp