11import * as path from "path" ;
2- import * as fs from "fs" ;
3- import util from "util" ;
2+ import * as fs from "fs-extra" ;
43import * as yamlParser from "js-yaml" ;
54import { getArg } from "./utils/args" ;
65import gitP , { SimpleGit } from "simple-git/promise" ;
76import { 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 ) ;
147
158async function validate ( args :string [ ] ) {
169// dir - default .
@@ -22,7 +15,7 @@ async function validate(args: string[]) {
2215yaml :getArg ( args , { name :"yaml" , alias :"y" } ) || "coderoad.yaml" ,
2316} ;
2417
25- const _yaml = await read ( path . join ( localDir , options . yaml ) , "utf8" ) ;
18+ const _yaml = await fs . readFile ( path . join ( localDir , options . yaml ) , "utf8" ) ;
2619
2720// parse yaml config
2821let skeleton ;
@@ -42,19 +35,22 @@ async function validate(args: string[]) {
4235const codeBranch :string = skeleton . config . repo . branch ;
4336
4437// validate commits
45- const commits = await getCommits ( { localDir, codeBranch} ) ;
38+ const commits :CommitLogObject = await getCommits ( { localDir, codeBranch} ) ;
39+ console . log ( "commits" , commits ) ;
4640
4741// setup tmp dir
4842const tmpDir = path . join ( localDir , ".tmp" ) ;
4943
5044try {
51- if ( ! ( await exists ( tmpDir ) ) ) {
52- await mkdir ( tmpDir ) ;
45+ if ( ! ( await fs . pathExists ( tmpDir ) ) ) {
46+ await fs . emptyDir ( tmpDir ) ;
5347}
5448const tempGit :SimpleGit = gitP ( tmpDir ) ;
5549await tempGit . init ( ) ;
5650
5751// VALIDATE TUTORIAL TESTS
52+ if ( commits . INIT ) {
53+ }
5854
5955// run test runner setup command(s)
6056// loop over commits:
@@ -75,7 +71,7 @@ async function validate(args: string[]) {
7571console . error ( e . message ) ;
7672} finally {
7773// cleanup
78- await rmdir ( tmpDir ) ;
74+ await fs . emptyDir ( tmpDir ) ;
7975}
8076}
8177