diff options
Diffstat (limited to 'packages/create-turbo/src/utils/isFolderEmpty.ts')
| -rw-r--r-- | packages/create-turbo/src/utils/isFolderEmpty.ts | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/packages/create-turbo/src/utils/isFolderEmpty.ts b/packages/create-turbo/src/utils/isFolderEmpty.ts new file mode 100644 index 0000000..4de2d58 --- /dev/null +++ b/packages/create-turbo/src/utils/isFolderEmpty.ts @@ -0,0 +1,37 @@ +import fs from "fs-extra"; + +const VALID_FILES = [ + ".DS_Store", + ".git", + ".gitattributes", + ".gitignore", + ".gitlab-ci.yml", + ".hg", + ".hgcheck", + ".hgignore", + ".idea", + ".npmignore", + ".travis.yml", + "LICENSE", + "Thumbs.db", + "docs", + "mkdocs.yml", + "npm-debug.log", + "yarn-debug.log", + "yarn-error.log", + "yarnrc.yml", + ".yarn", +]; + +export function isFolderEmpty(root: string): { + isEmpty: boolean; + conflicts: Array<string>; +} { + const conflicts = fs + .readdirSync(root) + .filter((file) => !VALID_FILES.includes(file)) + // Support IntelliJ IDEA-based editors + .filter((file) => !/\.iml$/.test(file)); + + return { isEmpty: conflicts.length === 0, conflicts }; +} |
