(workdir: string)
| 116 | } |
| 117 | |
| 118 | function entrypoint(workdir: string): string[] { |
| 119 | const isWindows = os.platform() === 'win32'; |
| 120 | const containerWorkdir = getContainerPath(workdir); |
| 121 | const shellCmds = []; |
| 122 | const pathSeparator = isWindows ? ';' : ':'; |
| 123 | |
| 124 | let pathSuffix = ''; |
| 125 | if (process.env['PATH']) { |
| 126 | const paths = process.env['PATH'].split(pathSeparator); |
| 127 | for (const p of paths) { |
| 128 | const containerPath = getContainerPath(p); |
| 129 | if ( |
| 130 | containerPath.toLowerCase().startsWith(containerWorkdir.toLowerCase()) |
| 131 | ) { |
| 132 | pathSuffix += `:${containerPath}`; |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | if (pathSuffix) { |
| 137 | shellCmds.push(`export PATH="$PATH${pathSuffix}";`); |
| 138 | } |
| 139 | |
| 140 | let pythonPathSuffix = ''; |
| 141 | if (process.env['PYTHONPATH']) { |
| 142 | const paths = process.env['PYTHONPATH'].split(pathSeparator); |
| 143 | for (const p of paths) { |
| 144 | const containerPath = getContainerPath(p); |
| 145 | if ( |
| 146 | containerPath.toLowerCase().startsWith(containerWorkdir.toLowerCase()) |
| 147 | ) { |
| 148 | pythonPathSuffix += `:${containerPath}`; |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | if (pythonPathSuffix) { |
| 153 | shellCmds.push(`export PYTHONPATH="$PYTHONPATH${pythonPathSuffix}";`); |
| 154 | } |
| 155 | |
| 156 | const projectSandboxBashrc = path.join( |
| 157 | SETTINGS_DIRECTORY_NAME, |
| 158 | 'sandbox.bashrc', |
| 159 | ); |
| 160 | if (fs.existsSync(projectSandboxBashrc)) { |
| 161 | shellCmds.push(`source ${getContainerPath(projectSandboxBashrc)};`); |
| 162 | } |
| 163 | |
| 164 | ports().forEach((p) => |
| 165 | shellCmds.push( |
| 166 | `socat TCP4-LISTEN:${p},bind=$(hostname -i),fork,reuseaddr TCP4:127.0.0.1:${p} 2> /dev/null &`, |
| 167 | ), |
| 168 | ); |
| 169 | |
| 170 | const cliArgs = process.argv.slice(2).map((arg) => quote([arg])); |
| 171 | const cliCmd = |
| 172 | process.env['NODE_ENV'] === 'development' |
| 173 | ? process.env['DEBUG'] |
| 174 | ? 'npm run debug --' |
| 175 | : 'npm rebuild && npm run start --' |
no test coverage detected