MCPcopy
hub / github.com/vitejs/vite / hasWorkspacePackageJSON

Function hasWorkspacePackageJSON

packages/vite/src/node/server/searchRoot.ts:25–36  ·  view source on GitHub ↗
(root: string)

Source from the content-addressed store, hash-verified

23// npm: https://docs.npmjs.com/cli/v7/using-npm/workspaces#installing-workspaces
24// yarn: https://classic.yarnpkg.com/en/docs/workspaces/#toc-how-to-use-it
25function hasWorkspacePackageJSON(root: string): boolean {
26 const path = join(root, 'package.json')
27 if (!isFileReadable(path)) {
28 return false
29 }
30 try {
31 const content = JSON.parse(fs.readFileSync(path, 'utf-8')) || {}
32 return !!content.workspaces
33 } catch {
34 return false
35 }
36}
37
38// https://docs.deno.com/runtime/fundamentals/workspaces/
39function hasWorkspaceDenoJSON(root: string): boolean {

Callers 1

searchForWorkspaceRootFunction · 0.85

Calls 2

isFileReadableFunction · 0.90
parseMethod · 0.80

Tested by

no test coverage detected