1
1
import * as path from "path" ;
2
- import * as fs from "fs" ;
3
- import util from "util" ;
2
+ import * as fs from "fs-extra" ;
4
3
import * as yamlParser from "js-yaml" ;
5
4
import { getArg } from "./utils/args" ;
6
5
import gitP , { SimpleGit } from "simple-git/promise" ;
7
6
import { getCommits , CommitLogObject } from "./utils/commits" ;
8
- import simplegit from "simple-git/promise" ;
9
-
10
- const mkdir = util . promisify ( fs . mkdir ) ;
11
- const exists = util . promisify ( fs . exists ) ;
12
- const rmdir = util . promisify ( fs . rmdir ) ;
13
- const read = util . promisify ( fs . readFile ) ;
14
7
15
8
async function validate ( args : string [ ] ) {
16
9
// dir - default .
@@ -22,7 +15,7 @@ async function validate(args: string[]) {
22
15
yaml : getArg ( args , { name : "yaml" , alias : "y" } ) || "coderoad.yaml" ,
23
16
} ;
24
17
25
- const _yaml = await read ( path . join ( localDir , options . yaml ) , "utf8" ) ;
18
+ const _yaml = await fs . readFile ( path . join ( localDir , options . yaml ) , "utf8" ) ;
26
19
27
20
// parse yaml config
28
21
let skeleton ;
@@ -42,19 +35,22 @@ async function validate(args: string[]) {
42
35
const codeBranch : string = skeleton . config . repo . branch ;
43
36
44
37
// validate commits
45
- const commits = await getCommits ( { localDir, codeBranch } ) ;
38
+ const commits : CommitLogObject = await getCommits ( { localDir, codeBranch } ) ;
39
+ console . log ( "commits" , commits ) ;
46
40
47
41
// setup tmp dir
48
42
const tmpDir = path . join ( localDir , ".tmp" ) ;
49
43
50
44
try {
51
- if ( ! ( await exists ( tmpDir ) ) ) {
52
- await mkdir ( tmpDir ) ;
45
+ if ( ! ( await fs . pathExists ( tmpDir ) ) ) {
46
+ await fs . emptyDir ( tmpDir ) ;
53
47
}
54
48
const tempGit : SimpleGit = gitP ( tmpDir ) ;
55
49
await tempGit . init ( ) ;
56
50
57
51
// VALIDATE TUTORIAL TESTS
52
+ if ( commits . INIT ) {
53
+ }
58
54
59
55
// run test runner setup command(s)
60
56
// loop over commits:
@@ -75,7 +71,7 @@ async function validate(args: string[]) {
75
71
console . error ( e . message ) ;
76
72
} finally {
77
73
// cleanup
78
- await rmdir ( tmpDir ) ;
74
+ await fs . emptyDir ( tmpDir ) ;
79
75
}
80
76
}
81
77
0 commit comments