@@ -27,6 +27,7 @@ const relativePath = (_path) => {
2727// COMPODOC
2828//
2929const buildCompodoc = ( packageJsonName , packageJsonVersion ) => {
30+ if ( shell . test ( '-d' , relativePath ( './documentation' ) ) ) shell . rm ( '-rf' , relativePath ( './documentation/' ) ) ;
3031 //
3132 // COMPODOC
3233 //
@@ -149,17 +150,14 @@ const buildPackage = (languageTarget, watch) => {
149150// INIT
150151//
151152const initialCleanup = ( ) => {
152- if ( shell . test ( '-d' , relativePath ( './documentation' ) ) ) shell . rm ( '-rf' , relativePath ( './documentation/' ) ) ;
153153 if ( shell . test ( '-d' , relativePath ( './dist' ) ) ) shell . rm ( '-rf' , relativePath ( './dist/' ) ) ;
154154 shell . mkdir ( relativePath ( './dist/' ) ) ;
155- if ( shell . test ( '-d' , relativePath ( './dist-demo' ) ) ) shell . rm ( '-rf' , relativePath ( './dist-demo/' ) ) ;
156155} ;
157156
158157if ( argv . watch ) {
159158 var gaze = new Gaze ( './src/**/*' ) ;
160159 gaze . on ( 'all' , ( event , filepath ) => {
161160 try {
162- //initialCleanup();
163161 buildPackage ( 'es5' , true ) ;
164162 buildPackage ( 'es2015' , true ) ;
165163 shell . echo ( chalk . green ( '>> ==============' ) ) ;
@@ -187,16 +185,28 @@ if (argv.watch) {
187185//
188186if ( argv . demo ) {
189187 shell . echo ( chalk . blue ( '>> creating dist-demo' ) ) ;
188+ if ( shell . test ( '-d' , relativePath ( './dist-demo' ) ) ) {
189+ if ( shell . test ( '-d' , relativePath ( './dist-demo/node_modules' ) ) ) {
190+ shell . echo ( chalk . blue ( '>> demo node_modules exists. retaining it.' ) ) ;
191+ shell . mv ( relativePath ( './dist-demo/node_modules' ) , relativePath ( './_dist_demo_node_modules' ) ) ;
192+ }
193+ shell . rm ( '-rf' , relativePath ( './dist-demo/' ) ) ;
194+ }
190195 shell . cp ( '-r' , `./node_modules/@cloukit/library-build-chain/demo-template` , `./dist-demo` ) ;
196+ if ( shell . test ( '-d' , relativePath ( './_dist_demo_node_modules' ) ) ) {
197+ shell . mv ( relativePath ( '_dist_demo_node_modules' ) , relativePath ( './dist-demo/node_modules' ) ) ;
198+ }
191199 shell . cp ( '-r' , `./src/*` , `./dist-demo/src/` ) ;
192200 const libraryImports = shell . cat ( './src/demo/demo.imports.txt' ) . stdout ;
193201 shell . sed ( '-i' ,
194202 '[/][*]___IMPORTS___[*][/]' ,
195203 libraryImports ,
196204 './dist-demo/src/app/app.module.ts' ) ;
197205 shell . cd ( relativePath ( './dist-demo/' ) ) ;
198- shell . echo ( chalk . blue ( '>> yarn install (this takes time!)' ) ) ;
199- shell . exec ( `yarn config set "strict-ssl" false && yarn` ) ;
206+ if ( argv . install ) {
207+ shell . echo ( chalk . blue ( '>> yarn install (this takes time!)' ) ) ;
208+ shell . exec ( `yarn config set "strict-ssl" false && yarn` ) ;
209+ }
200210 shell . echo ( chalk . blue ( '>> ng build' ) ) ;
201211 shell . exec ( `ng build` ) ;
202212 if ( argv . run ) {
0 commit comments