mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-25 05:03:10 +08:00
19 lines
447 B
TypeScript
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 });
|
|
}
|