@@ -14,6 +14,10 @@ const {
14
14
getUserCachePath
15
15
} = require ( './shared' ) ;
16
16
17
+ function quote_single ( quoteme ) {
18
+ return quote ( [ quoteme ] ) ;
19
+ }
20
+
17
21
/**
18
22
* Just generate the requirements file in the .serverless folder
19
23
* @param {string } requirementsPath
@@ -100,7 +104,7 @@ function installRequirements(targetFolder, serverless, options) {
100
104
) ;
101
105
serverless . cli . log ( `Using download cache directory ${ downloadCacheDir } ` ) ;
102
106
fse . ensureDirSync ( downloadCacheDir ) ;
103
- pipCmd . push ( '--cache-dir' , downloadCacheDir ) ;
107
+ pipCmd . push ( '--cache-dir' , quote_single ( downloadCacheDir ) ) ;
104
108
}
105
109
106
110
// Check if pip has Debian's --system option and set it if so
@@ -145,18 +149,23 @@ function installRequirements(targetFolder, serverless, options) {
145
149
// Prepare bind path depending on os platform
146
150
const bindPath = getBindPath ( serverless , targetFolder ) ;
147
151
148
- cmdOptions = [ 'run' , '--rm' , '-v' , `" ${ bindPath } :/var/task:z"` ] ;
152
+ cmdOptions = [ 'run' , '--rm' , '-v' , quote_single ( ` ${ bindPath } :/var/task:z` ) ] ;
149
153
if ( options . dockerSsh ) {
150
154
// Mount necessary ssh files to work with private repos
151
155
cmdOptions . push (
152
156
'-v' ,
153
- `" ${ process . env . HOME } /.ssh/id_rsa:/root/.ssh/id_rsa:z"`
157
+ quote_single ( ` ${ process . env . HOME } /.ssh/id_rsa:/root/.ssh/id_rsa:z` )
154
158
) ;
155
159
cmdOptions . push (
156
160
'-v' ,
157
- `"${ process . env . HOME } /.ssh/known_hosts:/root/.ssh/known_hosts:z"`
161
+ quote_single (
162
+ `${ process . env . HOME } /.ssh/known_hosts:/root/.ssh/known_hosts:z`
163
+ )
164
+ ) ;
165
+ cmdOptions . push (
166
+ '-v' ,
167
+ quote_single ( `${ process . env . SSH_AUTH_SOCK } :/tmp/ssh_sock:z` )
158
168
) ;
159
- cmdOptions . push ( '-v' , `"${ process . env . SSH_AUTH_SOCK } :/tmp/ssh_sock:z"` ) ;
160
169
cmdOptions . push ( '-e' , 'SSH_AUTH_SOCK=/tmp/ssh_sock' ) ;
161
170
}
162
171
@@ -177,8 +186,11 @@ function installRequirements(targetFolder, serverless, options) {
177
186
) ;
178
187
const windowsized = getBindPath ( serverless , downloadCacheDir ) ;
179
188
// And now push it to a volume mount and to pip...
180
- cmdOptions . push ( '-v' , `"${ windowsized } :${ dockerDownloadCacheDir } :z"` ) ;
181
- pipCmd . push ( '--cache-dir' , dockerDownloadCacheDir ) ;
189
+ cmdOptions . push (
190
+ '-v' ,
191
+ quote_single ( `${ windowsized } :${ dockerDownloadCacheDir } :z` )
192
+ ) ;
193
+ pipCmd . push ( '--cache-dir' , quote_single ( dockerDownloadCacheDir ) ) ;
182
194
}
183
195
184
196
if ( process . platform === 'linux' ) {
@@ -189,7 +201,7 @@ function installRequirements(targetFolder, serverless, options) {
189
201
commands . push ( quote ( [ 'chown' , '-R' , '0:0' , dockerDownloadCacheDir ] ) ) ;
190
202
}
191
203
// Install requirements with pip
192
- commands . push ( quote ( pipCmd ) ) ;
204
+ commands . push ( pipCmd . join ( ' ' ) ) ;
193
205
// Set the ownership of the current folder to user
194
206
commands . push (
195
207
quote ( [
@@ -213,7 +225,7 @@ function installRequirements(targetFolder, serverless, options) {
213
225
pipCmd = [ '/bin/bash' , '-c' , '"' + commands . join ( ' && ' ) + '"' ] ;
214
226
} else {
215
227
// Use same user so --cache-dir works
216
- cmdOptions . push ( '-u' , getDockerUid ( bindPath ) ) ;
228
+ cmdOptions . push ( '-u' , quote_single ( getDockerUid ( bindPath ) ) ) ;
217
229
}
218
230
cmdOptions . push ( dockerImage ) ;
219
231
cmdOptions . push ( ...pipCmd ) ;
@@ -262,7 +274,7 @@ function dockerPathForWin(options, path) {
262
274
if ( process . platform === 'win32' && options . dockerizePip ) {
263
275
return path . replace ( / \\ / g, '/' ) ;
264
276
}
265
- return path ;
277
+ return quote_single ( path ) ;
266
278
}
267
279
268
280
/** create a filtered requirements.txt without anything from noDeploy
0 commit comments