New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(misc): ensure plugins are not creating workspace context while creating nodes #22967
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export const GLOB = 'GLOB' as const; | ||
|
||
export type HandleGlobMessage = { | ||
type: typeof GLOB; | ||
globs: string[]; | ||
exclude?: string[]; | ||
}; | ||
|
||
export function isHandleGlobMessage( | ||
message: unknown | ||
): message is HandleGlobMessage { | ||
return ( | ||
typeof message === 'object' && | ||
message !== null && | ||
'type' in message && | ||
message['type'] === 'GLOB' | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { workspaceRoot } from '../../utils/workspace-root'; | ||
import { globWithWorkspaceContext } from '../../utils/workspace-context'; | ||
import { HandlerResult } from './server'; | ||
|
||
export async function handleGlob( | ||
globs: string[], | ||
exclude?: string[] | ||
): Promise<HandlerResult> { | ||
const files = await globWithWorkspaceContext(workspaceRoot, globs, exclude); | ||
return { | ||
response: JSON.stringify(files), | ||
description: 'handleGlob', | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,17 @@ | ||
import { daemonClient } from '../daemon/client/client'; | ||
import { isOnDaemon } from './is-on-daemon'; | ||
import { globWithWorkspaceContext } from './workspace-context'; | ||
import { workspaceRoot } from './workspace-root'; | ||
|
||
export function combineGlobPatterns(...patterns: (string | string[])[]) { | ||
const p = patterns.flat(); | ||
return p.length > 1 ? '{' + p.join(',') + '}' : p.length === 1 ? p[0] : ''; | ||
} | ||
|
||
export async function globAsync(globs: string[], exclude?: string[]) { | ||
if (isOnDaemon() || !daemonClient.enabled()) { | ||
return globWithWorkspaceContext(workspaceRoot, globs, exclude); | ||
} else { | ||
return daemonClient.glob(globs, exclude); | ||
} | ||
} | ||
Comment on lines
+11
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can do this in the Those functions should actually all go to the daemon... Things like Could we change them all? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function isOnDaemon() { | ||
return !!process.env.NX_ON_DAEMON_PROCESS; | ||
} | ||
Comment on lines
+1
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably live in the daemon directory? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can set a
global.NX_DAEMON = true
on the Daemon Server