@@ -54,20 +54,26 @@ function askConfiguration() {
54
54
validate : ( value ) => {
55
55
return value . length === 1 ? true : 'Expando char must be a single character'
56
56
}
57
+ } ,
58
+ {
59
+ type : 'confirm' ,
60
+ name : 'includeDotFiles' ,
61
+ message : 'Include gitignore and npm publish files?' ,
62
+ initial : true ,
57
63
}
58
64
] )
59
65
}
60
66
61
67
type Answers = Awaited < ReturnType < typeof askConfiguration > >
62
68
63
- function copyTemplate ( targetDir : string , skipDotFiles = false ) {
69
+ function copyTemplate ( targetDir : string , includeDotFiles : boolean ) {
64
70
const templateDir = path . join ( __dirname , 'template' )
65
71
return fs . cp ( templateDir , targetDir , {
66
72
recursive : true , // Copy all files and folders
67
- // includes hidden files if `skipDotFiles ` is false
73
+ // includes hidden files if `includeDotFiles ` is true
68
74
filter : ( src ) => {
69
75
const basename = path . basename ( src )
70
- return ! skipDotFiles || ! basename . startsWith ( '.' )
76
+ return includeDotFiles || ! basename . startsWith ( '.' )
71
77
}
72
78
} )
73
79
}
@@ -78,7 +84,7 @@ async function renameFiles(dir: string, answer: Answers) {
78
84
$$NAME$$ : answer . name ,
79
85
$$TREE_SITTER_PACKAGE$$ : answer . treeSitterPackage ,
80
86
$$EXTENSIONS$$ : JSON . stringify ( answer . extensions ) ,
81
- $$EXPANDO_CHAR$$ : JSON . stringify ( answer . expandoChar ) ,
87
+ $$EXPANDO_CHAR$$ : answer . expandoChar ,
82
88
}
83
89
for ( const file of await fs . readdir ( dir ) ) {
84
90
const filePath = path . join ( dir , file )
@@ -106,8 +112,7 @@ function installTreeSitterPackage(answer: Answers) {
106
112
async function main ( ) {
107
113
const cwd = process . cwd ( )
108
114
const config = await askConfiguration ( )
109
- const skipDotFiles = process . argv . slice ( 2 ) . includes ( '--skip-dot-files' )
110
- await copyTemplate ( cwd , skipDotFiles )
115
+ await copyTemplate ( cwd , config . includeDotFiles )
111
116
await renameFiles ( cwd , config )
112
117
installTreeSitterPackage ( config )
113
118
}
0 commit comments