File tree 2 files changed +25
-3
lines changed
2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -657,9 +657,13 @@ Emulate only the body of the API Gateway event.
657
657
_archivePrebuilt ( program ) {
658
658
const codeDirectory = this . _codeDirectory ( )
659
659
660
- return this . _fileCopy ( program , program . prebuiltDirectory , codeDirectory , false ) . then ( ( ) => {
661
- console . log ( '=> Zipping deployment package' )
662
- return this . _zip ( program , codeDirectory )
660
+ return Promise . resolve ( ) . then ( ( ) => {
661
+ return this . _cleanDirectory ( codeDirectory , program . keepNodeModules )
662
+ } ) . then ( ( ) => {
663
+ return this . _fileCopy ( program , program . prebuiltDirectory , codeDirectory , false ) . then ( ( ) => {
664
+ console . log ( '=> Zipping deployment package' )
665
+ return this . _zip ( program , codeDirectory )
666
+ } )
663
667
} )
664
668
}
665
669
Original file line number Diff line number Diff line change @@ -865,6 +865,24 @@ describe('lib/main', function () {
865
865
} )
866
866
} )
867
867
} )
868
+
869
+ it ( 'cleans the temporary directory before running `_archivePrebuilt`' , function ( ) {
870
+ _timeout ( { this : this , sec : 30 } ) // give it time to zip
871
+ const buildDir = '.build_' + Date . now ( )
872
+ const codeDir = lambda . _codeDirectory ( )
873
+ const tmpFile = path . join ( codeDir , 'deleteme' )
874
+ after ( ( ) => fs . removeSync ( buildDir ) )
875
+
876
+ fs . mkdirSync ( codeDir , { recursive : true } )
877
+ fs . writeFileSync ( tmpFile , '...' )
878
+ fs . mkdirSync ( buildDir )
879
+ fs . writeFileSync ( path . join ( buildDir , 'test' ) , '...' )
880
+
881
+ program . prebuiltDirectory = buildDir
882
+ return lambda . _archive ( program ) . then ( ( _data ) => {
883
+ assert . isNotTrue ( fs . existsSync ( tmpFile ) )
884
+ } )
885
+ } )
868
886
} )
869
887
870
888
describe ( '_readArchive' , ( ) => {
You can’t perform that action at this time.
0 commit comments