fix: ignore .git directory in init empty check (#208)
This commit is contained in:
+6
-6
@@ -20,6 +20,9 @@ OPTIONS:
|
|||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const CONFIRM_EMPTY_MESSAGE =
|
||||||
|
"The target directory is not empty (files could get overwritten). Do you want to continue anyway?";
|
||||||
|
|
||||||
export interface Args {
|
export interface Args {
|
||||||
help: boolean;
|
help: boolean;
|
||||||
}
|
}
|
||||||
@@ -48,12 +51,9 @@ async function init(directory: string) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const dir = [...Deno.readDirSync(directory)];
|
const dir = [...Deno.readDirSync(directory)];
|
||||||
if (
|
const isEmpty = dir.length === 0 ||
|
||||||
dir.length > 0 &&
|
dir.length === 1 && dir[0].name === ".git";
|
||||||
!confirm(
|
if (!isEmpty && !confirm(CONFIRM_EMPTY_MESSAGE)) {
|
||||||
"The target directory is not empty (files could get overwritten). Do you want to continue anyway?",
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
error("Directory is not empty.");
|
error("Directory is not empty.");
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user