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

Commit5b1a6dd

Browse files
committed
validate progress
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent46b64db commit5b1a6dd

File tree

2 files changed

+37
-30
lines changed

2 files changed

+37
-30
lines changed

‎src/validate.ts

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as yamlParser from "js-yaml";
55
import{getArg}from"./utils/args";
66
importgitP,{SimpleGit}from"simple-git/promise";
77
import{getCommits,CommitLogObject}from"./utils/commits";
8+
importsimplegitfrom"simple-git/promise";
89

910
constmkdir=util.promisify(fs.mkdir);
1011
constexists=util.promisify(fs.exists);
@@ -24,52 +25,58 @@ async function validate(args: string[]) {
2425
const_yaml=awaitread(path.join(localDir,options.yaml),"utf8");
2526

2627
// parse yaml config
27-
letconfig;
28+
letskeleton;
2829
try{
29-
config=yamlParser.load(_yaml);
30+
skeleton=yamlParser.load(_yaml);
31+
32+
console.log("config",skeleton);
3033
// TODO: validate yaml
31-
if(!config||!config.length){
34+
if(!skeleton){
3235
thrownewError("Invalid yaml file contents");
3336
}
3437
}catch(e){
3538
console.error("Error parsing yaml");
3639
console.error(e.message);
3740
}
3841

39-
constcodeBranch:string=config.config.repo.branch;
40-
41-
// VALIDATE SKELETON WITH COMMITS
42-
constcommits=getCommits({ localDir, codeBranch});
42+
constcodeBranch:string=skeleton.config.repo.branch;
4343

44-
// parse tutorial skeleton for order and commands
44+
// validate commits
45+
constcommits=awaitgetCommits({ localDir, codeBranch});
4546

46-
// on error, warn missing level/step
47+
// setup tmp dir
48+
consttmpDir=path.join(localDir,".tmp");
4749

48-
// VALIDATE COMMIT ORDER
49-
// list all commits in order
50-
// validate that a level number doesn't come before another level
51-
// validate that a step falls within a level
52-
// validate that steps are in order
50+
try{
51+
if(!(awaitexists(tmpDir))){
52+
awaitmkdir(tmpDir);
53+
}
54+
consttempGit:SimpleGit=gitP(tmpDir);
55+
awaittempGit.init();
5356

54-
// on error, show level/step out of order
57+
// VALIDATE TUTORIAL TESTS
5558

56-
// VALIDATE TUTORIAL TESTS
57-
// load INIT commit(s)
58-
// run test runner setup command(s)
59-
// loop over commits:
60-
// - load level commit
61-
// - run level setup command(s)
62-
// - load step setup commit(s)
63-
// - run step setup command(s)
64-
// - if next solution:
65-
// - run test - expect fail
66-
// - if solution
67-
// - run test - expect pass
59+
// run test runner setup command(s)
60+
// loop over commits:
61+
// - load level commit
62+
// - run level setup command(s)
63+
// - load step setup commit(s)
64+
// - run step setup command(s)
65+
// - if next solution:
66+
// - run test - expect fail
67+
// - if solution
68+
// - run test - expect pass
6869

69-
// log level/step
70-
// on error, show level/step & error message
70+
// log level/step
71+
// on error, show level/step & error message
7172

72-
// CLEANUP
73+
// load INIT commit(s)
74+
}catch(e){
75+
console.error(e.message);
76+
}finally{
77+
// cleanup
78+
awaitrmdir(tmpDir);
79+
}
7380
}
7481

7582
exportdefaultvalidate;
File renamed without changes.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp