Skip to content

Commit 30a7a26

Browse files
committed
fix(core): publish output config should be relative to workspace root
Closes #100
1 parent b8e88fa commit 30a7a26

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

packages/core/src/executors/publish/executor.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ import { rimraf } from '@nx-dotnet/utils';
1111

1212
import executor from './executor';
1313
import { PublishExecutorSchema } from './schema';
14+
import { isAbsolute } from 'path';
1415

1516
const options: PublishExecutorSchema = {
1617
configuration: 'Debug',
18+
output: 'dist/hello-world',
1719
};
1820

1921
const root = process.cwd() + '/tmp';
@@ -118,4 +120,21 @@ describe('Publish Executor', () => {
118120
expect(normalizePath(dotnetClient.cwd || '')).toEqual(directoryPath);
119121
expect(res.success).toBeTruthy();
120122
});
123+
124+
it('passes an absolute output path', async () => {
125+
const spy = jest.spyOn(dotnetClient, 'publish');
126+
const directoryPath = joinPathFragments(root, './apps/my-app');
127+
try {
128+
await fs.mkdir(directoryPath, { recursive: true });
129+
await Promise.all([fs.writeFile(`${directoryPath}/1.csproj`, '')]);
130+
} catch (e) {
131+
console.warn(e.message);
132+
}
133+
const res = await executor(options, context, dotnetClient);
134+
expect(spy).toHaveBeenCalled();
135+
const outputFlag = spy.mock.calls[0][1]?.find((x) => x.flag === 'output');
136+
expect(outputFlag).toBeTruthy();
137+
expect(outputFlag && isAbsolute(outputFlag.value as string)).toBeTruthy();
138+
expect(res.success).toBeTruthy();
139+
});
121140
});

packages/core/src/executors/publish/executor.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ export default async function runExecutor(
2626
nxProjectConfiguration,
2727
);
2828

29+
options.output = options.output
30+
? resolve(appRootPath, options.output)
31+
: undefined;
2932
const { publishProfile, extraParameters, ...flags } = options;
30-
flags.output = flags.output ? resolve(appRootPath, flags.output) : undefined;
3133

3234
dotnetClient.publish(
3335
resolve(appRootPath, projectFilePath),
3436
Object.keys(flags).map((x) => ({
3537
flag: x as dotnetPublishFlags,
36-
value: (options as Record<string, string | boolean>)[x],
38+
value: options[x as keyof PublishExecutorSchema],
3739
})),
3840
publishProfile,
3941
extraParameters,

0 commit comments

Comments
 (0)