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

Commitb5e4cb1

Browse files
authored
Merge pull request#15 from coderoad/feature/validate
Feature handle build issues
2 parentseb1fa80 +caa4276 commitb5e4cb1

File tree

4 files changed

+35
-30
lines changed

4 files changed

+35
-30
lines changed

‎src/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ async function build(args: string[]) {
124124
// write tutorial
125125
if(tutorial){
126126
try{
127-
awaitwrite(options.output,JSON.stringify(tutorial),"utf8");
127+
awaitwrite(options.output,JSON.stringify(tutorial,null,2),"utf8");
128128
console.info(`Success! See output at${options.output}`);
129129
}catch(e){
130130
console.error("Error writing tutorial json file:");

‎src/utils/commits.ts

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -45,41 +45,45 @@ export async function getCommits({
4545
thrownewError(`Code branch "${codeBranch}" not found`);
4646
}
4747

48-
console.log("branches",branches);
49-
50-
// Checkout the code branches
51-
awaitgit.checkout(codeBranch);
52-
53-
console.log("checked out");
54-
55-
// Load all logs
56-
constlogs=awaitgit.log();
57-
58-
console.log("logs",logs);
48+
// track the original branch in case of failure
49+
constoriginalBranch=branches.current;
5950

6051
// Filter relevant logs
6152
constcommits:CommitLogObject={};
6253

63-
for(constcommitoflogs.all){
64-
constmatches=commit.message.match(
65-
/^(?<stepId>(?<levelId>L\d+)(S\d+))(?<stepType>[QA])?/
66-
);
67-
68-
if(matches&&matches.length){
69-
// Use an object of commit arrays to collect all commits
70-
constposition=matches[0];
71-
if(!commits[position]){
72-
// does not exist, create the list
73-
commits[position]=[commit.hash];
74-
}else{
75-
// add to the list
76-
commits[position].push(commit.hash);
54+
try{
55+
// Checkout the code branches
56+
awaitgit.checkout(codeBranch);
57+
58+
// Load all logs
59+
constlogs=awaitgit.log();
60+
61+
for(constcommitoflogs.all){
62+
constmatches=commit.message.match(
63+
/^(?<stepId>(?<levelId>L\d+)(S\d+))(?<stepType>[QA])?/
64+
);
65+
66+
if(matches&&matches.length){
67+
// Use an object of commit arrays to collect all commits
68+
constposition=matches[0];
69+
if(!commits[position]){
70+
// does not exist, create the list
71+
commits[position]=[commit.hash];
72+
}else{
73+
// add to the list
74+
commits[position].push(commit.hash);
75+
}
7776
}
7877
}
78+
}catch(e){
79+
console.error("Error with checkout or commit matching");
80+
thrownewError(e.message);
81+
}finally{
82+
// revert back to the original branch on failure
83+
awaitgit.checkout(originalBranch);
84+
// cleanup the tmp directory
85+
awaitrmdir(tmpDir,{recursive:true});
7986
}
8087

81-
console.log("remove");
82-
// cleanup the tmp directory
83-
awaitrmdir(tmpDir,{recursive:true});
8488
returncommits;
8589
}

‎src/utils/parse.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export function parse(params: ParseParams): any {
9898
constmdContent:TutorialFrame=parseMdContent(params.text);
9999

100100
constparsed:Partial<T.Tutorial>={
101+
version:params.config.version,
101102
summary:mdContent.summary,
102103
config:params.config.config,
103104
levels:[],

‎src/utils/schema/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export default {
193193
"The solution commits that can be loaded if the user gets stuck. It can also run commands and/or open files",
194194
},
195195
{
196-
required:["commits"],
196+
required:[],
197197
},
198198
],
199199
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp