Skip to content

Commit

Permalink
Fix build when prompts folder does not exists (#546)
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgutgon authored Jun 27, 2024
1 parent 70bcccd commit 92113ec
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/wicked-dolphins-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latitude-data/cli": patch
---

Fix build failing when projects does not has a prompts folder
13 changes: 13 additions & 0 deletions packages/cli/core/src/lib/sync/syncPrompts/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { describe, expect, it, vi } from 'vitest'
import { syncDirectory } from './index'

describe('syncDirectory', () => {
it('does not fail when does not exists', () => {
const syncFn = vi.fn()
const folder = '/prompts/somthing.prompt'

syncDirectory(folder, syncFn)

expect(syncFn).not.toHaveBeenCalled()
})
})
2 changes: 2 additions & 0 deletions packages/cli/core/src/lib/sync/syncPrompts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ function buildDestPath({
}

export function syncDirectory(dirPath: string, syncFn: Function): void {
if (!existsSync(dirPath)) return

readdirSync(dirPath, { withFileTypes: true }).forEach((dirent) => {
const currentPath = path.join(dirPath, dirent.name)
if (dirent.isDirectory()) {
Expand Down

0 comments on commit 92113ec

Please sign in to comment.