Skip to content

Commit

Permalink
fix(core): publish output config should be relative to workspace root
Browse files Browse the repository at this point in the history
Closes #100
  • Loading branch information
AgentEnder committed Sep 15, 2021
1 parent b8e88fa commit 30a7a26
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
19 changes: 19 additions & 0 deletions packages/core/src/executors/publish/executor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
});
});
6 changes: 4 additions & 2 deletions packages/core/src/executors/publish/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string | boolean>)[x],
value: options[x as keyof PublishExecutorSchema],
})),
publishProfile,
extraParameters,
Expand Down

0 comments on commit 30a7a26

Please sign in to comment.