Skip to content

Commit 6b075ee

Browse files
author
John Doe
committed
refactor: fix targets
1 parent 08e9a68 commit 6b075ee

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

packages/nx-plugin/src/executors/cli/executor.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ export default async function runAutorunExecutor(
2727
mergedOptions,
2828
normalizedContext,
2929
);
30-
const { dryRun, verbose, command } = mergedOptions;
30+
const { dryRun, verbose, command, bin } = mergedOptions;
3131
const commandString = createCliCommandString({
3232
command,
3333
args: cliArgumentObject,
34+
bin,
3435
});
3536
if (verbose) {
3637
logger.info(`Run CLI executor ${command ?? ''}`);
@@ -41,7 +42,7 @@ export default async function runAutorunExecutor(
4142
} else {
4243
try {
4344
await executeProcess({
44-
...createCliCommandObject({ command, args: cliArgumentObject }),
45+
...createCliCommandObject({ command, args: cliArgumentObject, bin }),
4546
...(context.cwd ? { cwd: context.cwd } : {}),
4647
});
4748
} catch (error) {

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@ export function createExecutorTarget(options?: {
66
bin?: string;
77
projectPrefix?: string;
88
}): TargetConfiguration<ProjectPrefixOptions> {
9-
const { bin = PACKAGE_NAME, projectPrefix } = options ?? {};
9+
const { bin, projectPrefix } = options ?? {};
10+
1011
return {
11-
executor: `${bin}:cli`,
12-
...(projectPrefix
13-
? {
14-
options: {
15-
projectPrefix,
16-
},
17-
}
18-
: {}),
12+
executor: `${PACKAGE_NAME}:cli`,
13+
options: {
14+
...(bin ? { bin } : {}),
15+
...(projectPrefix ? { projectPrefix } : {}),
16+
},
1917
};
2018
}

packages/nx-plugin/src/plugin/target/executor.target.unit.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
import { expect } from 'vitest';
1+
import { describe, expect, it } from 'vitest';
22
import { createExecutorTarget } from './executor-target.js';
33

44
describe('createExecutorTarget', () => {
55
it('should return executor target without project name', () => {
66
expect(createExecutorTarget()).toStrictEqual({
77
executor: '@code-pushup/nx-plugin:cli',
8+
options: {},
89
});
910
});
1011

1112
it('should use bin if provides', () => {
12-
expect(createExecutorTarget({ bin: 'xyz' })).toStrictEqual({
13-
executor: 'xyz:cli',
13+
expect(
14+
createExecutorTarget({ bin: 'packages/cli/src/index.ts' }),
15+
).toStrictEqual({
16+
executor: '@code-pushup/nx-plugin:cli',
17+
options: {
18+
bin: 'packages/cli/src/index.ts',
19+
},
1420
});
1521
});
1622

packages/nx-plugin/src/plugin/target/targets.unit.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ describe('createTargets', () => {
109109
expect.objectContaining({
110110
[targetName]: {
111111
executor: `${PACKAGE_NAME}:cli`,
112+
options: {},
112113
},
113114
}),
114115
);
@@ -133,6 +134,7 @@ describe('createTargets', () => {
133134
).resolves.toStrictEqual({
134135
[DEFAULT_TARGET_NAME]: {
135136
executor: '@code-pushup/nx-plugin:cli',
137+
options: {},
136138
},
137139
});
138140
});
@@ -158,6 +160,7 @@ describe('createTargets', () => {
158160
).resolves.toStrictEqual({
159161
cp: {
160162
executor: '@code-pushup/nx-plugin:cli',
163+
options: {},
161164
},
162165
});
163166
});

0 commit comments

Comments
 (0)