@@ -8,7 +8,7 @@ import fs from 'node:fs'
88import path from "node:path" ;
99import { dirname } from 'node:path' ;
1010import { fileURLToPath } from 'node:url' ;
11- import { betaWarning , isDockerInstalled } from "../utils.js" ;
11+ import { betaWarning , isDirEmpty , isDockerInstalled } from "../utils.js" ;
1212
1313const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
1414
@@ -39,14 +39,15 @@ const action = async function (dir: string) {
3939 throw ( chalk . red ( "Error: You don't have Docker installed. It's the easiest way to get everything you need\n" ) + chalk . cyan ( "Please install Docker. For developers new to Docker, we suggest Orbstack: https://docs.orbstack.dev/quick-start" ) )
4040 }
4141
42- if ( fs . existsSync ( directory ) ) {
43- throw ( chalk . red ( ` Target directory (${ directory } ) already exists` ) )
42+ if ( fs . existsSync ( directory ) && ! isDirEmpty ( directory ) ) {
43+ throw ( chalk . redBright ( `Error: ` ) + ` Target directory (${ chalk . yellow ( directory ) } ) has files.\n\nPlease choose an empty or non-existent directory\n` )
4444 }
45+
4546 const parentDir = path . dirname ( directory )
4647
4748 try {
4849 fs . accessSync ( parentDir , fs . constants . W_OK )
49- } catch ( err ) {
50+ } catch ( err ) {
5051 console . error ( chalk . red ( `Can't write to ${ parentDir } . Please check permissions on the directory` ) )
5152 }
5253
@@ -68,7 +69,7 @@ const action = async function (dir: string) {
6869 validate : ( text ) => {
6970 if ( text . length == 0 ) {
7071 return 'Custom password is required'
71- } else if ( text . length < 8 ) {
72+ } else if ( text . length < 8 ) {
7273 return 'Password must be at least 8 characters (You can change this requirement later in your tenant password settings)'
7374 } else {
7475 return true
@@ -91,7 +92,7 @@ const action = async function (dir: string) {
9192 } , 500 )
9293 setTimeout ( ( ) => {
9394 console . log ( chalk . green ( `Creating Kickstart file` ) )
94- if ( ! fs . existsSync ( directory ) ) throw ( chalk . red ( `Something went wrong. ${ directory } does not exists.` ) )
95+ if ( ! fs . existsSync ( directory ) ) throw ( chalk . red ( `Something went wrong. ${ directory } does not exists.` ) )
9596 createKickstart ( __dirname + '/resources/kickstart/kickstart.json' , answers , directory )
9697 } , 1500 )
9798
0 commit comments