Skip to content

Commit 6643fe5

Browse files
committed
Double fix tests
1 parent 7032148 commit 6643fe5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/__tests__/cli.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
import { execSync } from "child_process";
2+
import { getConfigPath } from "../utils/utils";
3+
import fs from "fs";
24

35
export const cli = (args: any): string => {
6+
// Validate config path exists and a config file is there
7+
// You must have a valid config file before runnning tests!
8+
// If you don't have one, run the CLI to generate it
9+
const configPath = getConfigPath();
10+
if (!configPath) throw new Error("Could not find config path");
11+
try {
12+
fs.readFileSync(configPath);
13+
} catch (err: any) {
14+
throw new Error(err.message + "\nBefore running tests you must have a valid .treerc file - try running the cli first");
15+
}
16+
417
try {
518
const result = execSync(`ts-node src/index ${args.join(" ")}`);
619
return result.toString();

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { checkConfig } from "./utils/checkConfig";
2222

2323
// Check if config already exists, if not attempt to create it
2424
await checkConfig();
25-
2625
program
2726
.argument("[directory]", "directory to build structure from", ".")
2827
.option("-o, --output <output>", "location where command output should be stored")

0 commit comments

Comments
 (0)