@@ -9,9 +9,17 @@ const target = '.'
99function copyFile ( source , target ) {
1010 const targetFile = target + '/' + path . basename ( source )
1111
12- // If target is a directory, a new file with the same name will be created
12+ // Create the target directory if it doesn't exist
13+ const targetDir = path . dirname ( targetFile )
14+ if ( ! fs . existsSync ( targetDir ) ) {
15+ fs . mkdirSync ( targetDir , { recursive : true } )
16+ console . log ( targetDir + ' - Directory created.' )
17+ }
18+
19+ // If target is a file that doesn't exist, create it
1320 if ( ! fs . existsSync ( targetFile ) ) {
1421 console . log ( targetFile + ' - Created.' )
22+ fs . readFileSync ( source )
1523 fs . writeFileSync ( targetFile , fs . readFileSync ( source ) )
1624 }
1725 else {
@@ -33,7 +41,9 @@ function syncDir(directory) {
3341// Here we want to make sure our directories exist.
3442fs . mkdirSync ( './components/global' , { recursive : true } )
3543fs . mkdirSync ( './pages' , { recursive : true } )
44+ fs . mkdirSync ( './layouts' , { recursive : true } )
3645
3746syncDir ( 'pages' )
47+ syncDir ( 'layouts' )
3848syncDir ( 'components' )
3949copyFile ( scaffoldDir + '/app.vue' , target )
0 commit comments