@@ -7,7 +7,6 @@ import { fileURLToPath } from 'url'
77const __dirname = dirname ( fileURLToPath ( import . meta. url ) )
88
99const paramOr = ( map , arg , def ) => map . get ( arg ) || def
10- const valueOr = ( value , def ) => value || def
1110const makePath = ( ...p ) => Path . join ( ...p )
1211const ignoreContent =
1312 ( ...values ) =>
@@ -20,9 +19,12 @@ const FilesToIgnore = [
2019 '.vscode' ,
2120 '.github' ,
2221 '.husky/_' ,
22+ '.yarn' ,
2323 '.yarn/cache' ,
2424 '.yarn/build-state.yml' ,
2525 '.yarn/install-state.gz' ,
26+ '.yarnrc.yml' ,
27+ '.versionrc.js' ,
2628 'cmd' ,
2729 'coverage' ,
2830 'dist' ,
@@ -81,7 +83,7 @@ function main() {
8183 }
8284
8385 const source = makePath ( __dirname , '../..' )
84- const dest = valueOr ( argv [ 0 ] , process . cwd ( ) ) . trim ( )
86+ const dest = paramOr ( args , 'destination' , process . cwd ( ) ) . trim ( )
8587 const app = paramOr ( args , 'name' , 'my-app' ) . trim ( )
8688 const destination = makePath ( dest , app )
8789
@@ -99,7 +101,9 @@ App: ${app}
99101
100102 console . log ( 'Copying Templates ...' )
101103
102- Templates . forEach ( x => FsExt . copySync ( makePath ( source , 'templates' , x . file ) , makePath ( destination , x . copyTo ) ) )
104+ for ( const x of Templates ) {
105+ FsExt . copySync ( makePath ( source , 'templates' , x . file ) , makePath ( destination , x . copyTo ) )
106+ }
103107
104108 console . log ( 'Preparing package.json ...' )
105109
@@ -108,21 +112,21 @@ App: ${app}
108112 name : app ,
109113 }
110114
111- PkgFieldsToKeep . forEach ( field => {
115+ for ( const field of PkgFieldsToKeep ) {
112116 if ( typeof pkg [ field ] !== 'undefined' ) {
113117 newPkg [ field ] = pkg [ field ]
114118 }
115- } )
119+ }
116120
117- DepsToIgnore . forEach ( dep => {
121+ for ( const dep of DepsToIgnore ) {
118122 if ( pkg . dependencies [ dep ] ) {
119123 delete pkg . dependencies [ dep ]
120124 }
121125
122126 if ( pkg . devDependencies [ dep ] ) {
123127 delete pkg . dependencies [ dep ]
124128 }
125- } )
129+ }
126130
127131 FsExt . writeJsonSync ( makePath ( destination , 'package.json' ) , newPkg , { spaces : 2 } )
128132
0 commit comments