diff --git a/packages/core/src/executors/publish/executor.spec.ts b/packages/core/src/executors/publish/executor.spec.ts index 60eeaa6d..0e4ac728 100644 --- a/packages/core/src/executors/publish/executor.spec.ts +++ b/packages/core/src/executors/publish/executor.spec.ts @@ -11,9 +11,11 @@ import { rimraf } from '@nx-dotnet/utils'; import executor from './executor'; import { PublishExecutorSchema } from './schema'; +import { isAbsolute } from 'path'; const options: PublishExecutorSchema = { configuration: 'Debug', + output: 'dist/hello-world', }; const root = process.cwd() + '/tmp'; @@ -118,4 +120,21 @@ describe('Publish Executor', () => { expect(normalizePath(dotnetClient.cwd || '')).toEqual(directoryPath); expect(res.success).toBeTruthy(); }); + + it('passes an absolute output path', async () => { + const spy = jest.spyOn(dotnetClient, 'publish'); + const directoryPath = joinPathFragments(root, './apps/my-app'); + try { + await fs.mkdir(directoryPath, { recursive: true }); + await Promise.all([fs.writeFile(`${directoryPath}/1.csproj`, '')]); + } catch (e) { + console.warn(e.message); + } + const res = await executor(options, context, dotnetClient); + expect(spy).toHaveBeenCalled(); + const outputFlag = spy.mock.calls[0][1]?.find((x) => x.flag === 'output'); + expect(outputFlag).toBeTruthy(); + expect(outputFlag && isAbsolute(outputFlag.value as string)).toBeTruthy(); + expect(res.success).toBeTruthy(); + }); }); diff --git a/packages/core/src/executors/publish/executor.ts b/packages/core/src/executors/publish/executor.ts index 22d42c27..9f6b75e7 100644 --- a/packages/core/src/executors/publish/executor.ts +++ b/packages/core/src/executors/publish/executor.ts @@ -26,14 +26,16 @@ export default async function runExecutor( nxProjectConfiguration, ); + options.output = options.output + ? resolve(appRootPath, options.output) + : undefined; const { publishProfile, extraParameters, ...flags } = options; - flags.output = flags.output ? resolve(appRootPath, flags.output) : undefined; dotnetClient.publish( resolve(appRootPath, projectFilePath), Object.keys(flags).map((x) => ({ flag: x as dotnetPublishFlags, - value: (options as Record)[x], + value: options[x as keyof PublishExecutorSchema], })), publishProfile, extraParameters,