@@ -7,6 +7,7 @@ const Path = require('path');
77const ChildProcess = require ( 'child_process' ) ;
88const zipper = require ( 'zip-local' ) ;
99const upath = require ( 'upath' ) ;
10+ const readlineSync = require ( 'readline-sync' ) ;
1011
1112BbPromise . promisifyAll ( Fse ) ;
1213
@@ -89,7 +90,7 @@ class PkgPyFuncs {
8990 }
9091
9192 let cmd = 'pip'
92- let args = [ 'install' , '--upgrade' , '- t', upath . normalize ( buildPath ) , '-r' ]
93+ let args = [ 'install' , '-t' , upath . normalize ( buildPath ) , '-qq' , '-r' ]
9394 if ( this . useDocker === true ) {
9495 cmd = 'docker'
9596 args = [ 'exec' , this . containerName , 'pip' , ...args ]
@@ -111,25 +112,51 @@ class PkgPyFuncs {
111112 throw new this . serverless . classes . Error ( `[serverless-package-python-functions] ${ ret . error . message } ` )
112113 }
113114
115+ const out = ret . stdout . toString ( )
116+
114117 if ( ret . stderr . length != 0 ) {
115118 const errorText = ret . stderr . toString ( ) . trim ( )
116- console . log ( errorText )
117- this . error ( errorText )
118- // if (errorText.toLowerCase().search('error') != -1){
119- // this.log(errorText)
120- // console.log(errorText)
121- // this.error(errorText)
122- // }
119+ const countErrorNewLines = errorText . split ( '\n' ) . length
120+
121+ if ( countErrorNewLines < 2 && errorText . toLowerCase ( ) . includes ( 'git clone' ) ) {
122+ // Ignore false positive due to pip git clone printing to stderr
123+ console . log ( errorText )
124+ } else if ( errorText . toLowerCase ( ) . includes ( 'docker' ) ) {
125+ console . log ( 'stdout:' , out )
126+ console . log ( 'stderr: ' , errorText )
127+ this . error ( "Docker Error Detected" )
128+
129+ } else {
130+ // Error is not false positive,
131+ console . log ( '___ERROR DETECTED, BEGIN STDOUT____\n' , out )
132+ console . log ( '---BEGIN STDERR---\n' , errorText )
133+ this . requestUserConfirmation ( )
134+ }
135+
123136 }
124137
125- const out = ret . stdout . toString ( )
126138 return out
127139 }
128140
141+ requestUserConfirmation ( prompt = "\n\n??? Do you wish to continue deployment with the stated errors? \n" ,
142+ yesText = "Continuing Deployment!" ,
143+ noText = 'ABORTING DEPLOYMENT'
144+ ) {
145+ const response = readlineSync . question ( prompt ) ;
146+ if ( response . toLowerCase ( ) . includes ( 'y' ) ) {
147+ console . log ( yesText ) ;
148+ return
149+ } else {
150+ console . log ( noText )
151+ this . error ( 'Aborting' )
152+ return
153+ }
154+ }
129155
130156 setupContainer ( ) {
131157 let out = this . runProcess ( 'docker' , [ 'ps' , '-a' , '--filter' , `name=${ this . containerName } ` , '--format' , '{{.Names}}' ] )
132158 out = out . replace ( / ^ \s + | \s + $ / g, '' )
159+ console . log ( 'SDLFKJSDL:KFJSDL:KFJ ' , this . containerName )
133160
134161 if ( out === this . containerName ) {
135162 this . log ( 'Container already exists. Reusing.' )
0 commit comments