Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nitro-workflow-dirs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@workflow/nitro': patch
---

Respect the `workflow.dirs` Nitro module option when configuring workflow builders.
4 changes: 2 additions & 2 deletions packages/nitro/src/builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class VercelBuilder extends VercelBuildOutputAPIBuilder {
super({
...createBaseBuilderConfig({
workingDir: nitro.options.rootDir,
dirs: ['.'], // Different apps that use nitro have different directories
dirs: nitro.options.workflow?.dirs ?? ['.'], // Different apps that use nitro have different directories
runtime: nitro.options.workflow?.runtime,
sourcemap: nitro.options.workflow?.sourcemap,
externalPackages: getNitroStringExternals(nitro),
Expand Down Expand Up @@ -53,7 +53,7 @@ export class LocalBuilder extends BaseBuilder {
...createBaseBuilderConfig({
workingDir: nitro.options.rootDir,
watch: nitro.options.dev,
dirs: ['.'], // Different apps that use nitro have different directories
dirs: nitro.options.workflow?.dirs ?? ['.'], // Different apps that use nitro have different directories
sourcemap: nitro.options.workflow?.sourcemap,
externalPackages: getNitroStringExternals(nitro),
}),
Expand Down
30 changes: 29 additions & 1 deletion packages/nitro/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import nitroModule from './index.js';
function createNitroStub({
routing,
externals,
workflow,
}: {
routing: boolean;
externals?: {
external?: Array<string | RegExp | ((id: string) => boolean)>;
};
workflow?: Record<string, unknown>;
}) {
return {
routing,
Expand All @@ -23,7 +25,7 @@ function createNitroStub({
rootDir: '/tmp/project',
typescript: {},
virtual: {},
workflow: {},
workflow: workflow ?? {},
},
hooks: {
hook() {},
Expand Down Expand Up @@ -100,3 +102,29 @@ describe('@workflow/nitro externals forwarding', () => {
});
}
});

describe('@workflow/nitro workflow.dirs forwarding', () => {
for (const [label, Builder] of [
['VercelBuilder', VercelBuilder],
['LocalBuilder', LocalBuilder],
] as const) {
describe(label, () => {
it('keeps the Nitro-wide scan default when workflow.dirs is unset', () => {
const nitro = createNitroStub({ routing: true });
const builder = new Builder(nitro) as any;

expect(builder.config.dirs).toEqual(['.']);
});

it('forwards workflow.dirs to the workflow builder', () => {
const nitro = createNitroStub({
routing: true,
workflow: { dirs: ['workflows', 'src/jobs'] },
});
const builder = new Builder(nitro) as any;

expect(builder.config.dirs).toEqual(['workflows', 'src/jobs']);
});
});
}
});