MCPcopy
hub / github.com/serverless/serverless / tryBindPath

Function tryBindPath

packages/serverless/lib/plugins/python/lib/docker.js:88–127  ·  view source on GitHub ↗

* Test bind path to make sure it's working * @param {string} bindPath * @return {boolean}

(bindPath, testFile, pluginInstance)

Source from the content-addressed store, hash-verified

86 * @return {boolean}
87 */
88async 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

Callers 1

getBindPathFunction · 0.85

Calls 3

dockerCommandFunction · 0.85
debugMethod · 0.80
logMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…