Skip to content

Commit

Permalink
--output
Browse files Browse the repository at this point in the history
  • Loading branch information
johnstonmatt committed Dec 27, 2023
1 parent 3209d5e commit ece3d48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.0.2",
"version": "0.0.3",
"name": "bencher",
"deno_version": "1.39.0",
"tasks": {
Expand Down
7 changes: 5 additions & 2 deletions src/bencher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default async function bencher() {
.option("-r,--ref <ref:string>", "git ref of benchee", {
required: true,
})
.option("-o,--output <output:string>", "output file")
.description("benchmark a command")
.parse(Deno.args);

Expand Down Expand Up @@ -53,11 +54,13 @@ export default async function bencher() {
bencheeCommand: `${bencheePath} ${bencheeArgs.join(" ")}`,
};

const outputFilePath = options.output ?? path.join(cwd, "benchee.json");

let existingRecordText = "{}";

try {
existingRecordText = await Deno.readTextFile(
path.join(cwd, "benchee.json"),
outputFilePath,
);
} catch (_e) {
// benchee.json doesn't exist, we'll just create it
Expand All @@ -81,7 +84,7 @@ export default async function bencher() {
};

Deno.writeTextFile(
path.join(cwd, "benchee.json"),
outputFilePath,
JSON.stringify(newRecord, null, 2),
);

Expand Down

0 comments on commit ece3d48

Please sign in to comment.