MCPcopy
hub / github.com/vercel/next.js / validateAppDir

Method validateAppDir

packages/next-codemod/transforms/cra-to-next.ts:579–602  ·  view source on GitHub ↗
(files: string[])

Source from the content-addressed store, hash-verified

577 }
578
579 private validateAppDir(files: string[]) {
580 if (files.length > 1) {
581 fatalMessage(
582 `Error: only one directory should be provided for the cra-to-next transform, received ${files.join(
583 ', '
584 )}`
585 )
586 }
587 const appDir = path.join(process.cwd(), files[0])
588 let isValidDirectory = false
589
590 try {
591 isValidDirectory = fs.lstatSync(appDir).isDirectory()
592 } catch (err) {
593 // not a valid directory
594 }
595
596 if (!isValidDirectory) {
597 fatalMessage(
598 `Error: invalid directory provided for the cra-to-next transform, received ${appDir}`
599 )
600 }
601 return appDir
602 }
603}
604
605export default async function transformer(files, flags) {

Callers 1

constructorMethod · 0.95

Calls 3

fatalMessageFunction · 0.85
isDirectoryMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected