storybook/scripts/utils/package-json.ts
2022-10-03 17:16:39 +11:00

19 lines
447 B
TypeScript

import { readJSON, writeJSON } from 'fs-extra';
import { join } from 'path';
export async function addPackageScripts({
cwd,
scripts,
}: {
cwd: string;
scripts: Record<string, string>;
}) {
const packageJsonPath = join(cwd, 'package.json');
const packageJson = await readJSON(packageJsonPath);
packageJson.scripts = {
...packageJson.scripts,
...scripts,
};
await writeJSON(packageJsonPath, packageJson, { spaces: 2 });
}