This repository was archived by the owner on Jul 6, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +66
-0
lines changed Expand file tree Collapse file tree 2 files changed +66
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { green , blue } from 'https://deno.land/[email protected] /fmt/colors.ts'
2
+ import { join } from "https://deno.land/std/path/mod.ts"
3
+
4
+ export default function ( root : string , name : string ) : boolean {
5
+ const validFiles = [
6
+ '.DS_Store' ,
7
+ '.git' ,
8
+ '.gitattributes' ,
9
+ '.gitignore' ,
10
+ '.gitlab-ci.yml' ,
11
+ '.hg' ,
12
+ '.hgcheck' ,
13
+ '.hgignore' ,
14
+ '.idea' ,
15
+ '.travis.yml' ,
16
+ 'LICENSE' ,
17
+ 'Thumbs.db' ,
18
+ 'docs' ,
19
+ 'mkdocs.yml' ,
20
+ ]
21
+
22
+ const conflicts = [ ]
23
+
24
+ for ( const { name : file } of Deno . readDirSync ( root ) ) {
25
+ // Support IntelliJ IDEA-based editors
26
+ if ( validFiles . includes ( file ) || / \. i m l $ / . test ( file ) ) {
27
+ conflicts . push ( file )
28
+ }
29
+ }
30
+
31
+ if ( conflicts . length > 0 ) {
32
+ console . log (
33
+ `The directory ${ green ( name ) } contains files that could conflict:`
34
+ )
35
+ console . log ( )
36
+
37
+ for ( const file of conflicts ) {
38
+ try {
39
+ const stats = Deno . lstatSync ( join ( root , file ) )
40
+ if ( stats . isDirectory ) {
41
+ console . log ( ` ${ blue ( file ) } /` )
42
+ } else {
43
+ console . log ( ` ${ file } ` )
44
+ }
45
+ } catch {
46
+ console . log ( ` ${ file } ` )
47
+ }
48
+ }
49
+
50
+ console . log ( )
51
+ console . log (
52
+ 'Either try using a new directory name, or remove the files listed above.'
53
+ )
54
+ console . log ( )
55
+
56
+ return false
57
+ }
58
+
59
+ return true
60
+
61
+ }
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import util from '../shared/util.ts'
8
8
import { defaultReactVersion } from '../shared/constants.ts'
9
9
import { VERSION } from '../version.ts'
10
10
import { x_brotli , x_flate } from '../server/compress.ts'
11
+ import isFolderEmpty from './helpers/is-folder-empty.ts' ;
11
12
12
13
export const helpMessage = `
13
14
Usage:
@@ -28,6 +29,10 @@ export default async function (nameArg?: string) {
28
29
return
29
30
}
30
31
32
+ if ( ! isFolderEmpty ( cwd , name ) ) {
33
+ Deno . exit ( 1 )
34
+ }
35
+
31
36
const template = 'hello-world' // todo: add template select ui
32
37
const vscode = await confirm ( 'Add recommended workspace settings of VS Code?' )
33
38
You can’t perform that action at this time.
0 commit comments