@@ -42,6 +42,8 @@ const activeVariation = getActiveVariation();
4242if ( ! activeVariation ) return console . log ( color . red ( `No active variation found!\n${ color . yellow ( `Please select a variation first using ${ color . red ( '`npm run select`' ) } .` ) } ` ) ) ;
4343const variationDir = path . join ( rootPath , activeVariation . website , activeVariation . campaign , activeVariation . variation ) ;
4444if ( ! fs . existsSync ( path . join ( variationDir , 'dist' ) ) ) fs . mkdirSync ( path . join ( variationDir , 'dist' ) ) ;
45+ if ( ! fs . existsSync ( path . join ( variationDir , 'index.js' ) ) ) fs . writeFileSync ( path . join ( variationDir , 'index.js' ) , '' ) ;
46+ if ( ! fs . existsSync ( path . join ( variationDir , 'style.scss' ) ) ) fs . writeFileSync ( path . join ( variationDir , 'style.scss' ) , '' ) ;
4547
4648function compileCss ( variationDir ) {
4749 try {
@@ -68,7 +70,14 @@ function buildToDist(variationPath) {
6870 resolve ( ) ;
6971 } ) ;
7072}
71- if ( buildOnly ) return buildToDist ( variationDir ) . then ( ( ) => console . log ( color . green ( `Build completed successfully @ ${ color . italic ( `${ activeVariation . website } > ${ activeVariation . campaign } > ${ activeVariation . variation } ` ) } ` ) ) ) ;
73+ if ( buildOnly ) return buildToDist ( variationDir ) . then ( async ( ) => {
74+ console . log ( color . green ( `Build completed successfully & copied @ ${ color . italic ( `${ activeVariation . website } > ${ activeVariation . campaign } > ${ activeVariation . variation } ` ) } ` ) ) ;
75+ const cssToCopy = fs . readFileSync ( path . join ( variationDir , 'dist' , 'style.css' ) ) . toString ( ) ;
76+ clipboard . writeSync ( cssToCopy ) ;
77+ await ( ( ) => new Promise ( r => setTimeout ( r , 1e3 ) ) ) ( ) ;
78+ const jsToCopy = fs . readFileSync ( path . join ( variationDir , 'dist' , 'index.js' ) ) . toString ( ) ;
79+ clipboard . writeSync ( jsToCopy ) ;
80+ } ) ;
7281
7382app . get ( "/variation.js" , ( req , res ) => {
7483 return res . sendFile ( path . join ( variationDir , 'dist' , 'index.js' ) ) ;
0 commit comments