Skip to content

Commit 40a57fb

Browse files
committed
switch to fs-extra in validate
Signed-off-by: shmck <[email protected]>
1 parent 5b1a6dd commit 40a57fb

File tree

3 files changed

+52
-16
lines changed

3 files changed

+52
-16
lines changed

package-lock.json

+41-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"dependencies": {
5050
"ajv": "^6.12.2",
5151
"esm": "^3.2.25",
52+
"fs-extra": "^9.0.1",
5253
"js-yaml": "^3.14.0",
5354
"kleur": "^3.0.3",
5455
"lodash": "^4.17.15",
@@ -58,6 +59,7 @@
5859
"devDependencies": {
5960
"@babel/preset-typescript": "^7.10.1",
6061
"@types/ajv": "^1.0.0",
62+
"@types/fs-extra": "^9.0.1",
6163
"@types/inquirer": "^6.5.0",
6264
"@types/jest": "^25.2.3",
6365
"@types/js-yaml": "^3.12.4",

src/validate.ts

+9-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
import * as path from "path";
2-
import * as fs from "fs";
3-
import util from "util";
2+
import * as fs from "fs-extra";
43
import * as yamlParser from "js-yaml";
54
import { getArg } from "./utils/args";
65
import gitP, { SimpleGit } from "simple-git/promise";
76
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);
147

158
async function validate(args: string[]) {
169
// dir - default .
@@ -22,7 +15,7 @@ async function validate(args: string[]) {
2215
yaml: 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
2821
let skeleton;
@@ -42,19 +35,22 @@ async function validate(args: string[]) {
4235
const 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
4842
const tmpDir = path.join(localDir, ".tmp");
4943

5044
try {
51-
if (!(await exists(tmpDir))) {
52-
await mkdir(tmpDir);
45+
if (!(await fs.pathExists(tmpDir))) {
46+
await fs.emptyDir(tmpDir);
5347
}
5448
const tempGit: SimpleGit = gitP(tmpDir);
5549
await 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[]) {
7571
console.error(e.message);
7672
} finally {
7773
// cleanup
78-
await rmdir(tmpDir);
74+
await fs.emptyDir(tmpDir);
7975
}
8076
}
8177

0 commit comments

Comments
 (0)