From 1fa51345b9f2f5893b3ec8484fe223a63e80b15d Mon Sep 17 00:00:00 2001 From: Tomonori Tamura Date: Thu, 8 Nov 2018 10:31:22 +0900 Subject: [PATCH 1/5] calling spawnSync with 'windowsVerbatimArguments' option to prevent over escaping and quoating. --- lib/docker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/docker.js b/lib/docker.js index db2e81b5..0b817617 100644 --- a/lib/docker.js +++ b/lib/docker.js @@ -10,7 +10,7 @@ const path = require('path'); */ function dockerCommand(options) { const cmd = 'docker'; - const ps = spawnSync(cmd, options, { encoding: 'utf-8' }); + const ps = spawnSync(cmd, options, { encoding: 'utf-8', windowsVerbatimArguments: true }); if (ps.error) { if (ps.error.code === 'ENOENT') { throw new Error('docker not found! Please install it.'); From f40b6fb32a9f4f041aac5722ca99ab9dd9232685 Mon Sep 17 00:00:00 2001 From: Tomonori Tamura Date: Thu, 8 Nov 2018 10:39:55 +0900 Subject: [PATCH 2/5] fix: can not execute 'python.exe' on Docker container. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 155897ce..ee34bfca 100644 --- a/index.js +++ b/index.js @@ -36,7 +36,7 @@ class ServerlessPythonRequirements { usePipenv: true, pythonBin: process.platform === 'win32' - ? 'python.exe' + ? 'python' : this.serverless.service.provider.runtime || 'python', dockerizePip: false, dockerSsh: false, From 0af315242ee0adcb16134688749ecef3a7c3de49 Mon Sep 17 00:00:00 2001 From: Tomonori Tamura Date: Thu, 15 Nov 2018 01:49:51 +0900 Subject: [PATCH 3/5] fix: bindPath has space char. --- lib/docker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/docker.js b/lib/docker.js index 0b817617..e9aa23d1 100644 --- a/lib/docker.js +++ b/lib/docker.js @@ -134,7 +134,7 @@ function getBindPath(serverless, servicePath) { for (let i = 0; i < bindPaths.length; i++) { const bindPath = bindPaths[i]; - if (tryBindPath(serverless, bindPath, testFile)) { + if (tryBindPath(serverless, `"${bindPath}"`, testFile)) { return bindPath; } } From d060ea47292551abb0f01e8acba1af5cfd6b485f Mon Sep 17 00:00:00 2001 From: Tomonori Tamura Date: Thu, 15 Nov 2018 19:06:21 +0900 Subject: [PATCH 4/5] switch pythonBin from 'python.exe' to 'python' when dockerizePip and win32. --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index ee34bfca..c1526b74 100644 --- a/index.js +++ b/index.js @@ -36,7 +36,7 @@ class ServerlessPythonRequirements { usePipenv: true, pythonBin: process.platform === 'win32' - ? 'python' + ? 'python.exe' : this.serverless.service.provider.runtime || 'python', dockerizePip: false, dockerSsh: false, @@ -67,6 +67,9 @@ class ServerlessPythonRequirements { if (options.dockerizePip === 'non-linux') { options.dockerizePip = process.platform !== 'linux'; } + if (options.dockerizePip && process.platform === 'win32') { + options.pythonBin = 'python'; + } if ( !options.dockerizePip && (options.dockerSsh || options.dockerImage || options.dockerFile) From e827d4b81f219e498b090dcc3e923b822cc20ce6 Mon Sep 17 00:00:00 2001 From: Tomonori Tamura Date: Thu, 15 Nov 2018 20:00:06 +0900 Subject: [PATCH 5/5] fix format --- lib/docker.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/docker.js b/lib/docker.js index e9aa23d1..e38d653c 100644 --- a/lib/docker.js +++ b/lib/docker.js @@ -10,7 +10,10 @@ const path = require('path'); */ function dockerCommand(options) { const cmd = 'docker'; - const ps = spawnSync(cmd, options, { encoding: 'utf-8', windowsVerbatimArguments: true }); + const ps = spawnSync(cmd, options, { + encoding: 'utf-8', + windowsVerbatimArguments: true + }); if (ps.error) { if (ps.error.code === 'ENOENT') { throw new Error('docker not found! Please install it.');