Skip to content

Commit bbb45a5

Browse files
author
John Doe
committed
refactor: use pluginConfig in plugin
1 parent 8749e28 commit bbb45a5

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/nx-plugin/src/plugin/plugin.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {
77
CreateNodesV2,
88
} from '@nx/devkit';
99
import { PROJECT_JSON_FILE_NAME } from '../internal/constants.js';
10+
import { PLUGIN_NAME } from './constants.js';
1011
import { createTargets } from './target/targets.js';
1112
import type { CreateNodesOptions } from './types.js';
1213
import {
@@ -15,6 +16,9 @@ import {
1516
} from './utils.js';
1617

1718
// name has to be "createNodes" to get picked up by Nx <v20
19+
/**
20+
* @deprecated
21+
*/
1822
export const createNodes: CreateNodes = [
1923
`**/${PROJECT_JSON_FILE_NAME}`,
2024
async (
@@ -23,10 +27,14 @@ export const createNodes: CreateNodes = [
2327
context: CreateNodesContext,
2428
): Promise<CreateNodesResult> => {
2529
const parsedCreateNodesOptions = createNodesOptions as CreateNodesOptions;
30+
const pluginsConfig =
31+
context.nxJsonConfiguration.pluginsConfig?.[PLUGIN_NAME] ?? {};
32+
const mergedOptions = { ...pluginsConfig, ...parsedCreateNodesOptions };
33+
2634
const normalizedContext = await normalizedCreateNodesContext(
2735
context,
2836
projectConfigurationFile,
29-
parsedCreateNodesOptions,
37+
mergedOptions,
3038
);
3139

3240
return {
@@ -47,13 +55,16 @@ export const createNodesV2: CreateNodesV2<CreateNodesOptions> = [
4755
context: CreateNodesContextV2,
4856
): Promise<CreateNodesResultV2> => {
4957
const parsedCreateNodesOptions = createNodesOptions as CreateNodesOptions;
58+
const { pluginsConfig = {} } = context.nxJsonConfiguration;
59+
const pluginsConfigObj = pluginsConfig[PLUGIN_NAME] ?? {};
60+
const mergedOptions = { ...pluginsConfigObj, ...parsedCreateNodesOptions };
5061

5162
return await Promise.all(
5263
projectConfigurationFiles.map(async projectConfigurationFile => {
5364
const normalizedContext = await normalizedCreateNodesV2Context(
5465
context,
5566
projectConfigurationFile,
56-
parsedCreateNodesOptions,
67+
mergedOptions,
5768
);
5869

5970
const result: CreateNodesResult = {

0 commit comments

Comments
 (0)