MCPcopy Create free account
hub / github.com/webpack/webpack-cli / readFromPkgJSON

Function readFromPkgJSON

test/create-webpack-app/init/init.test.js:69–83  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

67// helper function to resolve the path from the test directory to actual assets
68// Helper to read from package.json in a given path
69const readFromPkgJSON = (path) => {
70 const pkgJSONPath = join(path, "package.json");
71
72 if (!existsSync(pkgJSONPath)) {
73 return {};
74 }
75
76 const pkgJSON = JSON.parse(readFileSync(pkgJSONPath, "utf8"));
77 const { devDependencies: devDeps } = pkgJSON;
78
79 // Update devDeps versions to be x.x.x to prevent frequent snapshot updates
80 for (const dep of Object.keys(devDeps)) devDeps[dep] = "x.x.x";
81
82 return { ...pkgJSON, devDependencies: devDeps };
83};
84
85// Helper to read from webpack.config.js or webpack.config.ts in a given path
86const readFromWebpackConfig = (path, filename = "webpack.config.js") =>

Callers 1

init.test.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected