Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(misc): ensure plugins are not creating workspace context while cr…
…eating nodes
- Loading branch information
1 parent
8ded380
commit 0cbad41
Showing
10 changed files
with
151 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function isOnDaemon() { | ||
return !!process.env.NX_ON_DAEMON_PROCESS; | ||
} |