mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
Merge pull request #1465 from mrzmyr/feat/throw-when-input-not-found
feat: throw when input not found
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'fumadocs-openapi': minor
|
||||
---
|
||||
|
||||
throw error, when input file is not found
|
||||
@@ -75,6 +75,14 @@ export async function generateFiles(options: Config): Promise<void> {
|
||||
...urlInputs,
|
||||
];
|
||||
|
||||
if (resolvedInputs.length === 0) {
|
||||
throw new Error(
|
||||
`No input files found. Tried resolving: ${
|
||||
typeof input === 'string' ? input : input.join(', ')
|
||||
}`,
|
||||
);
|
||||
}
|
||||
|
||||
function getOutputPaths(result: GeneratePageOutput): string[] {
|
||||
let file;
|
||||
|
||||
|
||||
@@ -84,6 +84,33 @@ describe('Generate documents', () => {
|
||||
expect(fs.mkdir).toBeCalledWith(join(cwd, './out'), expect.anything());
|
||||
});
|
||||
|
||||
test('Generate Files - throws error when no input files found', async () => {
|
||||
await expect(
|
||||
generateFiles({
|
||||
input: ['./fixtures/non-existent-*.yaml'],
|
||||
output: './out',
|
||||
per: 'file',
|
||||
cwd,
|
||||
}),
|
||||
).rejects.toThrow(
|
||||
'No input files found. Tried resolving: ./fixtures/non-existent-*.yaml',
|
||||
);
|
||||
|
||||
await expect(
|
||||
generateFiles({
|
||||
input: [
|
||||
'./fixtures/non-existent-1.yaml',
|
||||
'./fixtures/non-existent-2.yaml',
|
||||
],
|
||||
output: './out',
|
||||
per: 'file',
|
||||
cwd,
|
||||
}),
|
||||
).rejects.toThrow(
|
||||
'No input files found. Tried resolving: ./fixtures/non-existent-1.yaml, ./fixtures/non-existent-2.yaml',
|
||||
);
|
||||
});
|
||||
|
||||
test('Generate Files - groupBy tag per operation', async () => {
|
||||
await generateFiles({
|
||||
input: ['./fixtures/products.yaml'],
|
||||
|
||||
Reference in New Issue
Block a user