Skip to content

Instantly share code, notes, and snippets.

@thekbbohara
Created September 6, 2024 09:24
Show Gist options
  • Select an option

  • Save thekbbohara/a6e6abe715dd4a54ba1b48273cf7e44e to your computer and use it in GitHub Desktop.

Select an option

Save thekbbohara/a6e6abe715dd4a54ba1b48273cf7e44e to your computer and use it in GitHub Desktop.
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