Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed Jun 23, 2023
1 parent 6ad0c47 commit ca5dca9
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions scripts/bench/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@ export const saveBench = async (
data: Partial<BenchResults>,
options: SaveBenchOptions
) => {
const dirname = options.rootDir || process.cwd();
const existing = await ensureDir(dirname).then(() => {
return loadBench(options).catch(() => ({}));
const dirName = join(options.rootDir || process.cwd(), 'bench');
const fileName = `${key}.json`;
const existing = await ensureDir(dirName).then(() => {
return readJSON(join(dirName, fileName)).catch(() => ({}));
});
await writeJSON(join(dirname, `bench/${key}.json`), { ...existing, ...data }, { spaces: 2 });
await writeJSON(join(dirName, fileName), { ...existing, ...data }, { spaces: 2 });
};

export const loadBench = async (options: SaveBenchOptions): Promise<Partial<BenchResults>> => {
const dirname = options.rootDir || process.cwd();
const files = await readdir(join(dirname, `bench`));
return files.reduce(async (acc, file) => {
const data = await readJSON(join(dirname, `bench/${file}`));
const dirName = join(options.rootDir || process.cwd(), 'bench');
const files = await readdir(dirName);
return files.reduce(async (acc, fileName) => {
const data = await readJSON(join(dirName, fileName));
return { ...(await acc), ...data };
}, Promise.resolve({}));
// return readJSON(join(dirname, `bench.json`));
Expand Down

0 comments on commit ca5dca9

Please sign in to comment.