Resolve TODO: set cwd when launching doors; allow user to set in config
This commit is contained in:
parent
2fa9d6a3c2
commit
fa100c2da1
|
@ -149,6 +149,7 @@ exports.getModule = class AbracadabraModule extends MenuModule {
|
||||||
|
|
||||||
const exeInfo = {
|
const exeInfo = {
|
||||||
cmd : this.config.cmd,
|
cmd : this.config.cmd,
|
||||||
|
cwd : this.config.cwd, // null/undefined=path of |cwd|
|
||||||
args : this.config.args,
|
args : this.config.args,
|
||||||
io : this.config.io || 'stdio',
|
io : this.config.io || 'stdio',
|
||||||
encoding : this.config.encoding || this.client.term.outputEncoding,
|
encoding : this.config.encoding || this.client.term.outputEncoding,
|
||||||
|
|
|
@ -7,6 +7,7 @@ const { Errors } = require('./enig_error.js');
|
||||||
const pty = require('node-pty');
|
const pty = require('node-pty');
|
||||||
const decode = require('iconv-lite').decode;
|
const decode = require('iconv-lite').decode;
|
||||||
const createServer = require('net').createServer;
|
const createServer = require('net').createServer;
|
||||||
|
const paths = require('path');
|
||||||
|
|
||||||
module.exports = class Door {
|
module.exports = class Door {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
|
@ -55,12 +56,15 @@ module.exports = class Door {
|
||||||
return cb(Errors.UnexpectedState('Socket server is not running'));
|
return cb(Errors.UnexpectedState('Socket server is not running'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cwd = exeInfo.cwd || paths.dirname(exeInfo.cmd);
|
||||||
|
|
||||||
const formatObj = {
|
const formatObj = {
|
||||||
dropFile : exeInfo.dropFile,
|
dropFile : exeInfo.dropFile,
|
||||||
dropFilePath : exeInfo.dropFilePath,
|
dropFilePath : exeInfo.dropFilePath,
|
||||||
node : exeInfo.node.toString(),
|
node : exeInfo.node.toString(),
|
||||||
srvPort : this.sockServer ? this.sockServer.address().port.toString() : '-1',
|
srvPort : this.sockServer ? this.sockServer.address().port.toString() : '-1',
|
||||||
userId : this.client.user.userId.toString(),
|
userId : this.client.user.userId.toString(),
|
||||||
|
cwd : cwd,
|
||||||
};
|
};
|
||||||
|
|
||||||
const args = exeInfo.args.map( arg => stringFormat(arg, formatObj) );
|
const args = exeInfo.args.map( arg => stringFormat(arg, formatObj) );
|
||||||
|
@ -68,7 +72,7 @@ module.exports = class Door {
|
||||||
const door = pty.spawn(exeInfo.cmd, args, {
|
const door = pty.spawn(exeInfo.cmd, args, {
|
||||||
cols : this.client.term.termWidth,
|
cols : this.client.term.termWidth,
|
||||||
rows : this.client.term.termHeight,
|
rows : this.client.term.termHeight,
|
||||||
// :TODO: cwd
|
cwd : cwd,
|
||||||
env : exeInfo.env,
|
env : exeInfo.env,
|
||||||
encoding : null, // we want to handle all encoding ourself
|
encoding : null, // we want to handle all encoding ourself
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue