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

Commitc7bb8b0

Browse files
authored
Merge pull request#19 from coderoad/feature/init-hashes
Feature/init hashes
2 parents80ff618 +33d1f9e commitc7bb8b0

File tree

3 files changed

+113
-24
lines changed

3 files changed

+113
-24
lines changed

‎src/utils/commits.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ export async function getCommits({
7373
// add to the list
7474
commits[position].push(commit.hash);
7575
}
76+
}else{
77+
constinitMatches=commit.message.match(/^INIT/);
78+
if(initMatches&&initMatches.length){
79+
if(!commits.INIT){
80+
// does not exist, create the list
81+
commits.INIT=[commit.hash];
82+
}else{
83+
// add to the list
84+
commits.INIT.push(commit.hash);
85+
}
86+
}
7687
}
7788
}
7889
}catch(e){

‎src/utils/parse.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,20 @@ export function parse(params: ParseParams): any {
100100
constparsed:Partial<T.Tutorial>={
101101
version:params.config.version,
102102
summary:mdContent.summary,
103-
config:params.config.config,
103+
config:params.config.config||{},
104104
levels:[],
105105
};
106106

107+
// add init commits
108+
if(params.commits.INIT&&params.commits.INIT.length){
109+
console.log(JSON.stringify(parsed.config?.testRunner));
110+
//@ts-ignore
111+
parsed.config.testRunner.setup={
112+
...(parsed.config?.testRunner?.setup||{}),
113+
commits:params.commits.INIT,
114+
};
115+
}
116+
107117
// merge content and tutorial
108118
if(params.config.levels&&params.config.levels.length){
109119
parsed.levels=params.config.levels
@@ -119,12 +129,10 @@ export function parse(params: ParseParams): any {
119129
// add level setup commits
120130
constlevelSetupKey=level.id;
121131
if(params.commits[levelSetupKey]){
122-
if(!level.setup){
123-
level.setup={
124-
commits:[],
125-
};
126-
}
127-
level.setup.commits=params.commits[levelSetupKey];
132+
level.setup={
133+
...(level.setup||{}),
134+
commits:params.commits[levelSetupKey],
135+
};
128136
}
129137

130138
// add level step commits

‎tests/parse.test.ts

Lines changed: 87 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ The first step
437437
expect(result.levels[0].steps[0]).toEqual(expected.levels[0].steps[0]);
438438
});
439439

440-
it("should load the full config fora step",()=>{
440+
it("should load the full config formultiple levels & steps",()=>{
441441
constmd=`# Title
442442
443443
Description.
@@ -524,12 +524,12 @@ The third step
524524
text:md,
525525
config,
526526
commits:{
527-
L1S1Q:["abcdefg1","123456789"],
528-
L1S1A:["1gfedcba","987654321"],
529-
L1S2Q:["2abcdefg"],
530-
L1S2A:["3abcdefg"],
531-
L2S1Q:["4abcdefg"],
532-
L2S1A:["5abcdefg"],
527+
L1S1Q:["abcdef1","123456789"],
528+
L1S1A:["1fedcba","987654321"],
529+
L1S2Q:["2abcdef"],
530+
L1S2A:["3abcdef"],
531+
L2S1Q:["4abcdef"],
532+
L2S1A:["5abcdef"],
533533
},
534534
});
535535
constexpected={
@@ -547,15 +547,15 @@ The third step
547547
id:"L1S1",
548548
content:"The first step",
549549
setup:{
550-
commits:["abcdefg1","123456789"],
550+
commits:["abcdef1","123456789"],
551551
commands:["npm install"],
552552
files:["someFile.js"],
553553
watchers:["someFile.js"],
554554
filter:"someFilter",
555555
subtasks:true,
556556
},
557557
solution:{
558-
commits:["1gfedcba","987654321"],
558+
commits:["1fedcba","987654321"],
559559
commands:["npm install"],
560560
files:["someFile.js"],
561561
},
@@ -564,15 +564,15 @@ The third step
564564
id:"L1S2",
565565
content:"The second step",
566566
setup:{
567-
commits:["2abcdefg"],
567+
commits:["2abcdef"],
568568
commands:["npm install"],
569569
files:["someFile.js"],
570570
watchers:["someFile.js"],
571571
filter:"someFilter",
572572
subtasks:true,
573573
},
574574
solution:{
575-
commits:["3abcdefg"],
575+
commits:["3abcdef"],
576576
commands:["npm install"],
577577
files:["someFile.js"],
578578
},
@@ -589,15 +589,15 @@ The third step
589589
id:"L2S1",
590590
content:"The third step",
591591
setup:{
592-
commits:["4abcdefg"],
592+
commits:["4abcdef"],
593593
commands:["npm install"],
594594
files:["someFile.js"],
595595
watchers:["someFile.js"],
596596
filter:"someFilter",
597597
subtasks:true,
598598
},
599599
solution:{
600-
commits:["5abcdefg"],
600+
commits:["5abcdef"],
601601
commands:["npm install"],
602602
files:["someFile.js"],
603603
},
@@ -639,7 +639,7 @@ The first step
639639
text:md,
640640
config,
641641
commits:{
642-
L1S1Q:["abcdefg1","123456789"],
642+
L1S1Q:["abcdef1","123456789"],
643643
},
644644
});
645645
constexpected={
@@ -657,7 +657,7 @@ The first step
657657
id:"L1S1",
658658
content:"The first step",
659659
setup:{
660-
commits:["abcdefg1","123456789"],
660+
commits:["abcdef1","123456789"],
661661
},
662662
},
663663
],
@@ -684,7 +684,6 @@ Description.
684684
},
685685
directory:"coderoad",
686686
setup:{
687-
commits:["abcdefg1"],
688687
commands:[],
689688
},
690689
},
@@ -721,7 +720,6 @@ Description.
721720
},
722721
directory:"coderoad",
723722
setup:{
724-
commits:["abcdefg1"],
725723
commands:[],
726724
},
727725
},
@@ -742,4 +740,76 @@ Description.
742740
};
743741
expect(result.config).toEqual(expected.config);
744742
});
743+
744+
it("should parse the tutorial config with INIT commits",()=>{
745+
constmd=`# Title
746+
747+
Description.
748+
`;
749+
750+
constconfig={
751+
config:{
752+
testRunner:{
753+
command:"./node_modules/.bin/mocha",
754+
args:{
755+
filter:"--grep",
756+
tap:"--reporter=mocha-tap-reporter",
757+
},
758+
directory:"coderoad",
759+
},
760+
appVersions:{
761+
vscode:">=0.7.0",
762+
},
763+
repo:{
764+
uri:"https://path.to/repo",
765+
branch:"aBranch",
766+
},
767+
dependencies:[
768+
{
769+
name:"node",
770+
version:">=10",
771+
},
772+
],
773+
},
774+
};
775+
constresult=parse({
776+
text:md,
777+
config,
778+
commits:{
779+
INIT:["abcdef1","123456789"],
780+
},
781+
});
782+
constexpected={
783+
summary:{
784+
description:"Description.\n\nSecond description line",
785+
},
786+
config:{
787+
testRunner:{
788+
command:"./node_modules/.bin/mocha",
789+
args:{
790+
filter:"--grep",
791+
tap:"--reporter=mocha-tap-reporter",
792+
},
793+
directory:"coderoad",
794+
setup:{
795+
commits:["abcdef1","123456789"],
796+
},
797+
},
798+
repo:{
799+
uri:"https://path.to/repo",
800+
branch:"aBranch",
801+
},
802+
dependencies:[
803+
{
804+
name:"node",
805+
version:">=10",
806+
},
807+
],
808+
appVersions:{
809+
vscode:">=0.7.0",
810+
},
811+
},
812+
};
813+
expect(result.config).toEqual(expected.config);
814+
});
745815
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp