MCPcopy
hub / github.com/t3-oss/create-t3-app / addPackageScript

Function addPackageScript

cli/src/utils/addPackageScript.ts:6–25  ·  view source on GitHub ↗
(opts: {
  scripts: Record<string, string>;
  projectDir: string;
})

Source from the content-addressed store, hash-verified

4import { type PackageJson } from "type-fest";
5
6export const addPackageScript = (opts: {
7 scripts: Record<string, string>;
8 projectDir: string;
9}) => {
10 const { scripts, projectDir } = opts;
11
12 const packageJsonPath = path.join(projectDir, "package.json");
13 const packageJsonContent = fs.readJSONSync(packageJsonPath) as PackageJson;
14
15 packageJsonContent.scripts = {
16 ...packageJsonContent.scripts,
17 ...scripts,
18 };
19
20 const sortedPkgJson = sortPackageJson(packageJsonContent);
21
22 fs.writeJSONSync(packageJsonPath, sortedPkgJson, {
23 spaces: 2,
24 });
25};

Callers 4

dynamicEslintInstallerFunction · 0.85
prismaInstallerFunction · 0.85
drizzleInstallerFunction · 0.85
biomeInstallerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected