(wndopts, opts, cb)
| 1247 | } |
| 1248 | |
| 1249 | shell(wndopts, opts, cb) { |
| 1250 | if (!this._sock || !isWritable(this._sock)) |
| 1251 | throw new Error('Not connected'); |
| 1252 | |
| 1253 | if (typeof wndopts === 'function') { |
| 1254 | cb = wndopts; |
| 1255 | wndopts = opts = undefined; |
| 1256 | } else if (typeof opts === 'function') { |
| 1257 | cb = opts; |
| 1258 | opts = undefined; |
| 1259 | } |
| 1260 | if (wndopts && (wndopts.x11 !== undefined || wndopts.env !== undefined)) { |
| 1261 | opts = wndopts; |
| 1262 | wndopts = undefined; |
| 1263 | } |
| 1264 | |
| 1265 | openChannel(this, 'session', (err, chan) => { |
| 1266 | if (err) { |
| 1267 | cb(err); |
| 1268 | return; |
| 1269 | } |
| 1270 | |
| 1271 | const todo = []; |
| 1272 | |
| 1273 | function reqCb(err) { |
| 1274 | if (err) { |
| 1275 | chan.close(); |
| 1276 | cb(err); |
| 1277 | return; |
| 1278 | } |
| 1279 | if (todo.length) |
| 1280 | todo.shift()(); |
| 1281 | } |
| 1282 | |
| 1283 | if (this.config.allowAgentFwd === true |
| 1284 | || (opts |
| 1285 | && opts.agentForward === true |
| 1286 | && this._agent !== undefined)) { |
| 1287 | todo.push(() => reqAgentFwd(chan, reqCb)); |
| 1288 | } |
| 1289 | |
| 1290 | if (wndopts !== false) |
| 1291 | todo.push(() => reqPty(chan, wndopts, reqCb)); |
| 1292 | |
| 1293 | if (typeof opts === 'object' && opts !== null) { |
| 1294 | if (typeof opts.env === 'object' && opts.env !== null) |
| 1295 | reqEnv(chan, opts.env); |
| 1296 | if ((typeof opts.x11 === 'object' && opts.x11 !== null) |
| 1297 | || opts.x11 === 'number' |
| 1298 | || opts.x11 === true) { |
| 1299 | todo.push(() => reqX11(chan, opts.x11, reqCb)); |
| 1300 | } |
| 1301 | } |
| 1302 | |
| 1303 | todo.push(() => reqShell(chan, cb)); |
| 1304 | todo.shift()(); |
| 1305 | }); |
| 1306 |
no test coverage detected