@@ -6,6 +6,7 @@ const chai = require('chai');
66const sinon = require ( 'sinon' ) ;
77const mockery = require ( 'mockery' ) ;
88const Serverless = require ( 'serverless' ) ;
9+ const Configuration = require ( '../lib/Configuration' ) ;
910
1011chai . use ( require ( 'chai-as-promised' ) ) ;
1112chai . use ( require ( 'sinon-chai' ) ) ;
@@ -58,7 +59,8 @@ describe('cleanup', () => {
5859 options : {
5960 verbose : true
6061 } ,
61- webpackOutputPath : 'my/Output/Path'
62+ webpackOutputPath : 'my/Output/Path' ,
63+ configuration : new Configuration ( )
6264 } ,
6365 baseModule
6466 ) ;
@@ -88,16 +90,7 @@ describe('cleanup', () => {
8890 dirExistsSyncStub . returns ( true ) ;
8991 fseMock . remove . resolves ( true ) ;
9092
91- module = _ . assign (
92- {
93- serverless,
94- options : {
95- verbose : false
96- } ,
97- webpackOutputPath : 'my/Output/Path'
98- } ,
99- baseModule
100- ) ;
93+ module = _ . assign ( { } , module , { options : { verbose : false } } ) ;
10194
10295 return expect ( module . cleanup ( ) ) . to . be . fulfilled . then ( ( ) => {
10396 expect ( dirExistsSyncStub ) . to . have . been . calledOnce ;
@@ -142,4 +135,18 @@ describe('cleanup', () => {
142135 return null ;
143136 } ) ;
144137 } ) ;
138+
139+ it ( 'should keep output dir if keepOutputDir = true in configuration' , ( ) => {
140+ dirExistsSyncStub . returns ( true ) ;
141+
142+ const configuredModule = _ . assign ( { } , module , {
143+ configuration : new Configuration ( { webpack : { keepOutputDirectory : true } } )
144+ } ) ;
145+
146+ return expect ( configuredModule . cleanup ( ) ) . to . be . fulfilled . then ( ( ) => {
147+ expect ( dirExistsSyncStub ) . to . not . have . been . calledOnce ;
148+ expect ( fseMock . remove ) . to . not . have . been . called ;
149+ return null ;
150+ } ) ;
151+ } ) ;
145152} ) ;
0 commit comments