Skip to content

Commit 9934bf7

Browse files
authored
Windows Only: When call spawnSyc with shell=true, enclosing by double… (#288)
…-quate -v option. Remove enclosing by double-quate at dockerPathForWin on Windows platform. It's caused bad effect on spawnSync without shell=true or windowsVerbatimArguments=true. closes #274 closes #281
1 parent d162be3 commit 9934bf7

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ class ServerlessPythonRequirements {
6969
if (options.dockerizePip === 'non-linux') {
7070
options.dockerizePip = process.platform !== 'linux';
7171
}
72+
if (options.dockerizePip && process.platform === 'win32') {
73+
options.pythonBin = 'python';
74+
}
7275
if (
7376
!options.dockerizePip &&
7477
(options.dockerSsh || options.dockerImage || options.dockerFile)

lib/pip.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ function quote_single(quoteme) {
1818
return quote([quoteme]);
1919
}
2020

21+
function quoteFroWin(quoteme) {
22+
if (process.platform === 'win32') {
23+
return `"${quoteme}"`;
24+
}
25+
return quoteme;
26+
}
27+
2128
/**
2229
* Just generate the requirements file in the .serverless folder
2330
* @param {string} requirementsPath
@@ -152,7 +159,7 @@ function installRequirements(targetFolder, serverless, options) {
152159
getBindPath(serverless, targetFolder)
153160
);
154161

155-
cmdOptions = ['run', '--rm', '-v', `${bindPath}:/var/task:z`];
162+
cmdOptions = ['run', '--rm', '-v', quoteFroWin(`${bindPath}:/var/task:z`)];
156163
if (options.dockerSsh) {
157164
// Mount necessary ssh files to work with private repos
158165
cmdOptions.push(
@@ -282,7 +289,7 @@ function installRequirements(targetFolder, serverless, options) {
282289
*/
283290
function dockerPathForWin(options, path) {
284291
if (process.platform === 'win32') {
285-
return `"${path.replace(/\\/g, '/')}"`;
292+
return `${path.replace(/\\/g, '/')}`;
286293
} else if (process.platform === 'win32' && !options.dockerizePip) {
287294
return path;
288295
}

0 commit comments

Comments
 (0)