1
1
import { Untar } from 'https://deno.land/[email protected] /archive/tar.ts'
2
- import { green , dim } from 'https://deno.land/[email protected] /fmt/colors.ts'
2
+ import { green , blue , dim } from 'https://deno.land/[email protected] /fmt/colors.ts'
3
3
import { ensureDir } from 'https://deno.land/[email protected] /fs/ensure_dir.ts'
4
4
import { join } from 'https://deno.land/[email protected] /path/mod.ts'
5
5
import { gunzip } from 'https://deno.land/x/[email protected] /mod.ts'
@@ -8,7 +8,6 @@ import util from '../shared/util.ts'
8
8
import { defaultReactVersion } from '../shared/constants.ts'
9
9
import { VERSION } from '../version.ts'
10
10
import { deno_x_brotli , deno_x_flate } from '../server/compress.ts'
11
- import isFolderEmpty from './helpers/is-folder-empty.ts' ;
12
11
13
12
export const helpMessage = `
14
13
Usage:
@@ -129,3 +128,50 @@ async function confirm(question: string = 'are you sure?') {
129
128
while ( ! / ^ ( y ( e s ) ? | n o ? ) $ / i. test ( a = ( await ask ( question + ' ' + dim ( '[y/n]' ) ) ) . trim ( ) ) ) { }
130
129
return a . charAt ( 0 ) . toLowerCase ( ) === 'y'
131
130
}
131
+
132
+ function isFolderEmpty ( root : string , name : string ) : boolean {
133
+ const validFiles = [
134
+ '.DS_Store' ,
135
+ '.git' ,
136
+ '.gitattributes' ,
137
+ '.gitignore' ,
138
+ '.gitlab-ci.yml' ,
139
+ '.hg' ,
140
+ '.hgcheck' ,
141
+ '.hgignore' ,
142
+ '.idea' ,
143
+ '.travis.yml' ,
144
+ 'LICENSE' ,
145
+ 'Thumbs.db' ,
146
+ 'docs' ,
147
+ 'mkdocs.yml' ,
148
+ ]
149
+
150
+ const conflicts = [ ]
151
+
152
+ for ( const { name : file , isDirectory } of Deno . readDirSync ( root ) ) {
153
+ // Support IntelliJ IDEA-based editors
154
+ if ( validFiles . includes ( file ) || / \. i m l $ / . test ( file ) ) {
155
+ if ( isDirectory ) {
156
+ conflicts . push ( blue ( file ) + '/' )
157
+ } else {
158
+ conflicts . push ( file )
159
+ }
160
+ }
161
+ }
162
+
163
+ if ( conflicts . length > 0 ) {
164
+ console . log (
165
+ [
166
+ `The directory ${ green ( name ) } contains files that could conflict:` ,
167
+ '' ,
168
+ ...conflicts ,
169
+ '' ,
170
+ 'Either try using a new directory name, or remove the files listed above.'
171
+ ] . join ( '\n' )
172
+ )
173
+ return false
174
+ }
175
+
176
+ return true
177
+ }
0 commit comments