* Test bind path to make sure it's working * @param {string} bindPath * @return {boolean}
(bindPath, testFile, pluginInstance)
| 86 | * @return {boolean} |
| 87 | */ |
| 88 | async function tryBindPath(bindPath, testFile, pluginInstance) { |
| 89 | const { serverless, log } = pluginInstance |
| 90 | const debug = process.env.SLS_DEBUG |
| 91 | const options = [ |
| 92 | 'run', |
| 93 | '--rm', |
| 94 | '-v', |
| 95 | `${bindPath}:/test`, |
| 96 | 'alpine', |
| 97 | 'ls', |
| 98 | `/test/${testFile}`, |
| 99 | ] |
| 100 | try { |
| 101 | if (debug) { |
| 102 | if (log) { |
| 103 | log.debug(`Trying bindPath ${bindPath} (${options})`) |
| 104 | } else { |
| 105 | serverless.cli.log(`Trying bindPath ${bindPath} (${options})`) |
| 106 | } |
| 107 | } |
| 108 | const ps = await dockerCommand(options, pluginInstance) |
| 109 | if (debug) { |
| 110 | if (log) { |
| 111 | log.debug(ps.stdoutBuffer.toString().trim()) |
| 112 | } else { |
| 113 | serverless.cli.log(ps.stdoutBuffer.toString().trim()) |
| 114 | } |
| 115 | } |
| 116 | return ps.stdoutBuffer.toString().trim() === `/test/${testFile}` |
| 117 | } catch (err) { |
| 118 | if (debug) { |
| 119 | if (log) { |
| 120 | log.debug(`Finding bindPath failed with ${err}`) |
| 121 | } else { |
| 122 | serverless.cli.log(`Finding bindPath failed with ${err}`) |
| 123 | } |
| 124 | } |
| 125 | return false |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Get bind path depending on os platform |
no test coverage detected
searching dependent graphs…