Skip to content

Commit 37ab8ef

Browse files
committed
fix(cli): default output path in same dir with recipe
1 parent a6038a2 commit 37ab8ef

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/cli.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22

33
import { existsSync, writeFileSync } from "fs";
4-
import { join } from "path";
4+
import { join, dirname, basename } from "path";
55
import { Generator, recipe, testcase, generateMode } from "./";
66

77
if (
@@ -62,11 +62,11 @@ const testcases = generator.gen(mode);
6262
const EndTime = Date.now();
6363

6464
if (mode === "simple") {
65-
if (!outputPath) outputPath = join(process.cwd(), "testcases.txt");
65+
if (!outputPath) outputPath = join(dirname(recipePath), basename(basename(recipePath, ".js"), ".tc") + ".txt");
6666
writeFileSync(outputPath, testcases as string, "utf-8");
6767
console.log("\u001b[92m" + `Testcases generated in ${EndTime - StartTime}ms at ${outputPath}.` + "\u001b[0m");
6868
} else {
69-
if (!outputPath) outputPath = join(process.cwd(), "testcases.json");
69+
if (!outputPath) outputPath = join(dirname(recipePath), basename(basename(recipePath, ".js"), ".tc") + ".tc.json");
7070
writeFileSync(outputPath, JSON.stringify(testcases as testcase[], null, 2), "utf-8");
7171
console.log("\u001b[92m" + `${(testcases as testcase[]).length} testcases generated in ${EndTime - StartTime}ms at ${outputPath}.` + "\u001b[0m");
7272
}

0 commit comments

Comments
 (0)