@@ -30,17 +30,25 @@ function addVendorHelper() {
3030 } )
3131 . then ( ( functions ) => uniqBy ( functions , ( func ) => func . module ) )
3232 . map ( ( f ) => {
33- this . serverless . cli . log (
34- `Adding Python requirements helper to ${ f . module } ...`
35- ) ;
33+ if ( this . log ) {
34+ this . log . info ( `Adding Python requirements helper to ${ f . module } ` ) ;
35+ } else {
36+ this . serverless . cli . log (
37+ `Adding Python requirements helper to ${ f . module } ...`
38+ ) ;
39+ }
3640
3741 return fse . copyAsync (
3842 path . resolve ( __dirname , '../unzip_requirements.py' ) ,
3943 path . join ( this . servicePath , f . module , 'unzip_requirements.py' )
4044 ) ;
4145 } ) ;
4246 } else {
43- this . serverless . cli . log ( 'Adding Python requirements helper...' ) ;
47+ if ( this . log ) {
48+ this . log . info ( 'Adding Python requirements helper' ) ;
49+ } else {
50+ this . serverless . cli . log ( 'Adding Python requirements helper...' ) ;
51+ }
4452
4553 if ( ! get ( this . serverless . service , 'package.patterns' ) ) {
4654 set ( this . serverless . service , [ 'package' , 'patterns' ] , [ ] ) ;
@@ -72,15 +80,25 @@ function removeVendorHelper() {
7280 } )
7381 . then ( ( funcs ) => uniqBy ( funcs , ( f ) => f . module ) )
7482 . map ( ( f ) => {
75- this . serverless . cli . log (
76- `Removing Python requirements helper from ${ f . module } ...`
77- ) ;
83+ if ( this . log ) {
84+ this . log . info (
85+ `Removing Python requirements helper from ${ f . module } `
86+ ) ;
87+ } else {
88+ this . serverless . cli . log (
89+ `Removing Python requirements helper from ${ f . module } ...`
90+ ) ;
91+ }
7892 return fse . removeAsync (
7993 path . join ( this . servicePath , f . module , 'unzip_requirements.py' )
8094 ) ;
8195 } ) ;
8296 } else {
83- this . serverless . cli . log ( 'Removing Python requirements helper...' ) ;
97+ if ( this . log ) {
98+ this . log . info ( 'Removing Python requirements helper' ) ;
99+ } else {
100+ this . serverless . cli . log ( 'Removing Python requirements helper...' ) ;
101+ }
84102 return fse . removeAsync (
85103 path . join ( this . servicePath , 'unzip_requirements.py' )
86104 ) ;
@@ -104,21 +122,46 @@ function packRequirements() {
104122 } )
105123 . then ( ( funcs ) => uniqBy ( funcs , ( f ) => f . module ) )
106124 . map ( ( f ) => {
107- this . serverless . cli . log (
108- `Zipping required Python packages for ${ f . module } ...`
109- ) ;
125+ let packProgress ;
126+ if ( this . progress ) {
127+ packProgress = this . progress . get (
128+ `python-pack-requirements-${ f . module } `
129+ ) ;
130+ packProgress . update (
131+ `Zipping required Python packages for ${ f . module } ` ,
132+ { isMainEvent : true }
133+ ) ;
134+ } else {
135+ this . serverless . cli . log (
136+ `Zipping required Python packages for ${ f . module } ...`
137+ ) ;
138+ }
110139 f . package . patterns . push ( `${ f . module } /.requirements.zip` ) ;
111- return addTree (
112- new JSZip ( ) ,
113- `.serverless/${ f . module } /requirements`
114- ) . then ( ( zip ) => writeZip ( zip , `${ f . module } /.requirements.zip` ) ) ;
140+ return addTree ( new JSZip ( ) , `.serverless/${ f . module } /requirements` )
141+ . then ( ( zip ) => writeZip ( zip , `${ f . module } /.requirements.zip` ) )
142+ . then ( ( ) => packProgress && packProgress . remove ( ) )
143+ . catch ( ( e ) => {
144+ packProgress && packProgress . remove ( ) ;
145+ throw e ;
146+ } ) ;
115147 } ) ;
116148 } else {
117- this . serverless . cli . log ( 'Zipping required Python packages...' ) ;
149+ let packProgress ;
150+ if ( this . progress ) {
151+ packProgress = this . progress . get ( `python-pack-requirements` ) ;
152+ } else {
153+ this . serverless . cli . log ( 'Zipping required Python packages...' ) ;
154+ }
118155 this . serverless . service . package . patterns . push ( '.requirements.zip' ) ;
119- return addTree ( new JSZip ( ) , '.serverless/requirements' ) . then ( ( zip ) =>
120- writeZip ( zip , path . join ( this . servicePath , '.requirements.zip' ) )
121- ) ;
156+ return addTree ( new JSZip ( ) , '.serverless/requirements' )
157+ . then ( ( zip ) =>
158+ writeZip ( zip , path . join ( this . servicePath , '.requirements.zip' ) )
159+ )
160+ . then ( ( ) => packProgress && packProgress . remove ( ) )
161+ . catch ( ( e ) => {
162+ packProgress && packProgress . remove ( ) ;
163+ throw e ;
164+ } ) ;
122165 }
123166 }
124167}
0 commit comments