Skip to content

Commit 92113ec

Browse files
authored
Fix build when prompts folder does not exists (#546)
1 parent 70bcccd commit 92113ec

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@latitude-data/cli": patch
3+
---
4+
5+
Fix build failing when projects does not has a prompts folder
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { describe, expect, it, vi } from 'vitest'
2+
import { syncDirectory } from './index'
3+
4+
describe('syncDirectory', () => {
5+
it('does not fail when does not exists', () => {
6+
const syncFn = vi.fn()
7+
const folder = '/prompts/somthing.prompt'
8+
9+
syncDirectory(folder, syncFn)
10+
11+
expect(syncFn).not.toHaveBeenCalled()
12+
})
13+
})

packages/cli/core/src/lib/sync/syncPrompts/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ function buildDestPath({
3737
}
3838

3939
export function syncDirectory(dirPath: string, syncFn: Function): void {
40+
if (!existsSync(dirPath)) return
41+
4042
readdirSync(dirPath, { withFileTypes: true }).forEach((dirent) => {
4143
const currentPath = path.join(dirPath, dirent.name)
4244
if (dirent.isDirectory()) {

0 commit comments

Comments
 (0)