Created
September 6, 2024 09:24
-
-
Save thekbbohara/a6e6abe715dd4a54ba1b48273cf7e44e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const getSrcDir = async (cwd: string): Promise<string> => { | |
| cwd = cwd || process.cwd(); | |
| const files = await readdir(cwd); | |
| if (files.includes("src")) return resolve(cwd, "src"); | |
| if (files.includes("package.json")) { | |
| await mkdir(resolve(cwd, "src")); | |
| return resolve(cwd, "src"); | |
| } | |
| return await getSrcDir(resolve(cwd, "..")); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment