MCPcopy Create free account
hub / github.com/TanStack/cli / validateDevWatchOptions

Function validateDevWatchOptions

packages/cli/src/command-line.ts:562–609  ·  view source on GitHub ↗
(cliOptions: CliOptions)

Source from the content-addressed store, hash-verified

560}
561
562export function validateDevWatchOptions(cliOptions: CliOptions): {
563 valid: boolean
564 error?: string
565} {
566 if (!cliOptions.devWatch) {
567 return { valid: true }
568 }
569
570 // Validate watch path exists
571 const watchPath = resolve(process.cwd(), cliOptions.devWatch)
572 if (!fs.existsSync(watchPath)) {
573 return {
574 valid: false,
575 error: `Watch path does not exist: ${watchPath}`,
576 }
577 }
578
579 // Validate it's a directory
580 const stats = fs.statSync(watchPath)
581 if (!stats.isDirectory()) {
582 return {
583 valid: false,
584 error: `Watch path is not a directory: ${watchPath}`,
585 }
586 }
587
588 // Ensure target directory is specified
589 if (!cliOptions.projectName && !cliOptions.targetDir) {
590 return {
591 valid: false,
592 error: 'Project name or target directory is required for dev watch mode',
593 }
594 }
595
596 // Check for framework structure
597 const hasAddOns = fs.existsSync(resolve(watchPath, 'add-ons'))
598 const hasAssets = fs.existsSync(resolve(watchPath, 'assets'))
599 const hasFrameworkJson = fs.existsSync(resolve(watchPath, 'framework.json'))
600
601 if (!hasAddOns && !hasAssets && !hasFrameworkJson) {
602 return {
603 valid: false,
604 error: `Watch path does not appear to be a valid framework directory: ${watchPath}`,
605 }
606 }
607
608 return { valid: true }
609}

Callers 1

startDevWatchModeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected