beam-cli
Version:
A beautifully simple CLI for running Lighthouse audits on a statically generated (SSG) website
17 lines (16 loc) • 664 B
JavaScript
import fs from 'node:fs/promises';
import { ensureDirectoryExistence } from '../fs/directory.js';
import { saveJSONFile } from '../fs/json.js';
/**
* Saves the summary results for all the runs to local output folder
* - This file is used when the cli is started with the `viewlast` flag as a way
* to view and explore the results without running all the tests again.
*/
export const saveResultsToDisk = async (results, folder) => {
const directory = `./${folder}`;
if (!ensureDirectoryExistence(directory)) {
await fs.mkdir(directory);
}
const filePath = `${directory}/.last-results.json`;
await saveJSONFile(filePath, results);
};