Skip to content

Feature/validate #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
switch to fs-extra in validate
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
  • Loading branch information
ShMcK committed Jun 13, 2020
commit 40a57fb181a7735af3858f041c4d027814f7d987
44 changes: 41 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"dependencies": {
"ajv": "^6.12.2",
"esm": "^3.2.25",
"fs-extra": "^9.0.1",
"js-yaml": "^3.14.0",
"kleur": "^3.0.3",
"lodash": "^4.17.15",
Expand All @@ -58,6 +59,7 @@
"devDependencies": {
"@babel/preset-typescript": "^7.10.1",
"@types/ajv": "^1.0.0",
"@types/fs-extra": "^9.0.1",
"@types/inquirer": "^6.5.0",
"@types/jest": "^25.2.3",
"@types/js-yaml": "^3.12.4",
Expand Down
22 changes: 9 additions & 13 deletions src/validate.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import * as path from "path";
import * as fs from "fs";
import util from "util";
import * as fs from "fs-extra";
import * as yamlParser from "js-yaml";
import { getArg } from "./utils/args";
import gitP, { SimpleGit } from "simple-git/promise";
import { getCommits, CommitLogObject } from "./utils/commits";
import simplegit from "simple-git/promise";

const mkdir = util.promisify(fs.mkdir);
const exists = util.promisify(fs.exists);
const rmdir = util.promisify(fs.rmdir);
const read = util.promisify(fs.readFile);

async function validate(args: string[]) {
// dir - default .
Expand All @@ -22,7 +15,7 @@ async function validate(args: string[]) {
yaml: getArg(args, { name: "yaml", alias: "y" }) || "coderoad.yaml",
};

const _yaml = await read(path.join(localDir, options.yaml), "utf8");
const _yaml = await fs.readFile(path.join(localDir, options.yaml), "utf8");

// parse yaml config
let skeleton;
Expand All @@ -42,19 +35,22 @@ async function validate(args: string[]) {
const codeBranch: string = skeleton.config.repo.branch;

// validate commits
const commits = await getCommits({ localDir, codeBranch });
const commits: CommitLogObject = await getCommits({ localDir, codeBranch });
console.log("commits", commits);

// setup tmp dir
const tmpDir = path.join(localDir, ".tmp");

try {
if (!(await exists(tmpDir))) {
await mkdir(tmpDir);
if (!(await fs.pathExists(tmpDir))) {
await fs.emptyDir(tmpDir);
}
const tempGit: SimpleGit = gitP(tmpDir);
await tempGit.init();

// VALIDATE TUTORIAL TESTS
if (commits.INIT) {
}

// run test runner setup command(s)
// loop over commits:
Expand All @@ -75,7 +71,7 @@ async function validate(args: string[]) {
console.error(e.message);
} finally {
// cleanup
await rmdir(tmpDir);
await fs.emptyDir(tmpDir);
}
}

Expand Down