MCPcopy Create free account
hub / github.com/ProNextJS/declarative-routing / addPackageJSONScripts

Function addPackageJSONScripts

src/shared/utils.ts:19–39  ·  view source on GitHub ↗
(scripts: Record<string, string>)

Source from the content-addressed store, hash-verified

17}
18
19export function addPackageJSONScripts(scripts: Record<string, string>) {
20 const packageJsonPath = path.resolve("./package.json");
21 const packageJson = fs.readJSONSync(packageJsonPath) as PackageJson;
22
23 const newPackageJson = {
24 ...packageJson,
25 scripts: {
26 ...packageJson.scripts
27 }
28 };
29 for (const key of Object.keys(scripts)) {
30 if (!newPackageJson.scripts[key]) {
31 newPackageJson.scripts[key] = scripts[key];
32 }
33 }
34
35 return fs.writeJSONSync(packageJsonPath, newPackageJson, {
36 spaces: 2,
37 EOL: "\n"
38 });
39}
40
41export async function getPackageManager(): Promise<
42 "yarn" | "pnpm" | "bun" | "npm"

Callers 2

setupFunction · 0.90
setupFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected