mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-09 00:19:13 +08:00
17 lines
528 B
TypeScript
17 lines
528 B
TypeScript
import { join } from 'path';
|
|
import { ensureDir, writeJSON } from 'fs-extra';
|
|
|
|
export const now = () => new Date().getTime();
|
|
|
|
interface SaveBenchOptions {
|
|
key: 'build' | 'dev' | 'bench-build' | 'bench-dev';
|
|
rootDir?: string;
|
|
}
|
|
|
|
export const saveBench = async (data: any, options: SaveBenchOptions) => {
|
|
console.log('save', options.key);
|
|
const dirname = join(options.rootDir || process.cwd(), 'bench-results');
|
|
await ensureDir(dirname);
|
|
await writeJSON(join(dirname, `${options.key}.json`), data, { spaces: 2 });
|
|
};
|