dropFileType is now optional when using abracadabra
* Can be left out or set to 'none' * Allows doors that do not use a drop file * Additionally: Clean up drop file upon door exit if one is used
This commit is contained in:
parent
12ca811476
commit
f202600571
|
@ -17,6 +17,7 @@ This document attempts to track **major** changes and additions in ENiGMA½. For
|
||||||
* The [./docs/modding/onelinerz.md](onelinerz) module can have `dbSuffix` set in it's `config` block to specify a separate DB file. For example to use as a requests list.
|
* The [./docs/modding/onelinerz.md](onelinerz) module can have `dbSuffix` set in it's `config` block to specify a separate DB file. For example to use as a requests list.
|
||||||
* Default hash tags can now be set in file areas. Simply supply an array or list of values in a file area block via `hashTags`.
|
* Default hash tags can now be set in file areas. Simply supply an array or list of values in a file area block via `hashTags`.
|
||||||
* Added ability to pass an `env` value (map) to `abracadabra` doors. See [Local Doors](./docs/modding/local-doors.md]).
|
* Added ability to pass an `env` value (map) to `abracadabra` doors. See [Local Doors](./docs/modding/local-doors.md]).
|
||||||
|
* `dropFileType` is now optional when launching doors with `abracadabra`. It can also be explicitly set to `none`.
|
||||||
|
|
||||||
## 0.0.11-beta
|
## 0.0.11-beta
|
||||||
* Upgraded from `alpha` to `beta` -- The software is far along and mature enough at this point!
|
* Upgraded from `alpha` to `beta` -- The software is far along and mature enough at this point!
|
||||||
|
|
|
@ -11,12 +11,14 @@ const {
|
||||||
trackDoorRunBegin,
|
trackDoorRunBegin,
|
||||||
trackDoorRunEnd
|
trackDoorRunEnd
|
||||||
} = require('./door_util.js');
|
} = require('./door_util.js');
|
||||||
|
const Log = require('./logger').log;
|
||||||
|
|
||||||
// deps
|
// deps
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const paths = require('path');
|
const paths = require('path');
|
||||||
|
const fs = require('graceful-fs');
|
||||||
|
|
||||||
const activeDoorNodeInstances = {};
|
const activeDoorNodeInstances = {};
|
||||||
|
|
||||||
|
@ -70,20 +72,12 @@ exports.getModule = class AbracadabraModule extends MenuModule {
|
||||||
// :TODO: MenuModule.validateConfig(cb) -- validate config section gracefully instead of asserts! -- { key : type, key2 : type2, ... }
|
// :TODO: MenuModule.validateConfig(cb) -- validate config section gracefully instead of asserts! -- { key : type, key2 : type2, ... }
|
||||||
// .. and/or EnigAssert
|
// .. and/or EnigAssert
|
||||||
assert(_.isString(this.config.name, 'Config \'name\' is required'));
|
assert(_.isString(this.config.name, 'Config \'name\' is required'));
|
||||||
assert(_.isString(this.config.dropFileType, 'Config \'dropFileType\' is required'));
|
|
||||||
assert(_.isString(this.config.cmd, 'Config \'cmd\' is required'));
|
assert(_.isString(this.config.cmd, 'Config \'cmd\' is required'));
|
||||||
|
|
||||||
this.config.nodeMax = this.config.nodeMax || 0;
|
this.config.nodeMax = this.config.nodeMax || 0;
|
||||||
this.config.args = this.config.args || [];
|
this.config.args = this.config.args || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
:TODO:
|
|
||||||
* disconnecting while door is open leaves dosemu
|
|
||||||
* http://bbslink.net/sysop.php support
|
|
||||||
* Font support ala all other menus... or does this just work?
|
|
||||||
*/
|
|
||||||
|
|
||||||
incrementActiveDoorNodeInstances() {
|
incrementActiveDoorNodeInstances() {
|
||||||
if(activeDoorNodeInstances[this.config.name]) {
|
if(activeDoorNodeInstances[this.config.name]) {
|
||||||
activeDoorNodeInstances[this.config.name] += 1;
|
activeDoorNodeInstances[this.config.name] += 1;
|
||||||
|
@ -141,11 +135,15 @@ exports.getModule = class AbracadabraModule extends MenuModule {
|
||||||
return self.doorInstance.prepare(self.config.io || 'stdio', callback);
|
return self.doorInstance.prepare(self.config.io || 'stdio', callback);
|
||||||
},
|
},
|
||||||
function generateDropfile(callback) {
|
function generateDropfile(callback) {
|
||||||
const dropFileOpts = {
|
if (!self.config.dropFileType || self.config.dropFileType.toLowerCase() === 'none') {
|
||||||
fileType : self.config.dropFileType,
|
return callback(null);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
self.dropFile = new DropFile(
|
||||||
|
self.client,
|
||||||
|
{ fileType : self.config.dropFileType }
|
||||||
|
);
|
||||||
|
|
||||||
self.dropFile = new DropFile(self.client, dropFileOpts);
|
|
||||||
return self.dropFile.createFile(callback);
|
return self.dropFile.createFile(callback);
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -170,18 +168,30 @@ exports.getModule = class AbracadabraModule extends MenuModule {
|
||||||
args : this.config.args,
|
args : this.config.args,
|
||||||
io : this.config.io || 'stdio',
|
io : this.config.io || 'stdio',
|
||||||
encoding : this.config.encoding || 'cp437',
|
encoding : this.config.encoding || 'cp437',
|
||||||
dropFile : this.dropFile.fileName,
|
|
||||||
dropFilePath : this.dropFile.fullPath,
|
|
||||||
node : this.client.node,
|
node : this.client.node,
|
||||||
env : this.config.env,
|
env : this.config.env,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (this.dropFile) {
|
||||||
|
exeInfo.dropFile = this.dropFile.fileName;
|
||||||
|
exeInfo.dropFilePath = this.dropFile.fullPath;
|
||||||
|
}
|
||||||
|
|
||||||
const doorTracking = trackDoorRunBegin(this.client, this.config.name);
|
const doorTracking = trackDoorRunBegin(this.client, this.config.name);
|
||||||
|
|
||||||
this.doorInstance.run(exeInfo, () => {
|
this.doorInstance.run(exeInfo, () => {
|
||||||
trackDoorRunEnd(doorTracking);
|
trackDoorRunEnd(doorTracking);
|
||||||
this.decrementActiveDoorNodeInstances();
|
this.decrementActiveDoorNodeInstances();
|
||||||
|
|
||||||
|
// Clean up dropfile, if any
|
||||||
|
if (exeInfo.dropFilePath) {
|
||||||
|
fs.unlink(exeInfo.dropFilePath, err => {
|
||||||
|
if (err) {
|
||||||
|
Log.warn({ error : err, path : exeInfo.dropFilePath }, 'Failed to remove drop file.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// client may have disconnected while process was active -
|
// client may have disconnected while process was active -
|
||||||
// we're done here if so.
|
// we're done here if so.
|
||||||
if(!this.client.term.output) {
|
if(!this.client.term.output) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ The `abracadabra` `config` block can contain the following members:
|
||||||
| Item | Required | Description |
|
| Item | Required | Description |
|
||||||
|------|----------|-------------|
|
|------|----------|-------------|
|
||||||
| `name` | :+1: | Used as a key for tracking number of clients using a particular door. |
|
| `name` | :+1: | Used as a key for tracking number of clients using a particular door. |
|
||||||
| `dropFileType` | :+1: | Specifies the type of dropfile to generate (See **Dropfile Types** below). |
|
| `dropFileType` | :-1: | Specifies the type of dropfile to generate (See **Dropfile Types** below). Can be omitted or set to `none`. |
|
||||||
| `cmd` | :+1: | Path to executable to launch. |
|
| `cmd` | :+1: | Path to executable to launch. |
|
||||||
| `args` | :-1: | Array of argument(s) to pass to `cmd`. See **Argument Variables** below for information on variables that can be used here.
|
| `args` | :-1: | Array of argument(s) to pass to `cmd`. See **Argument Variables** below for information on variables that can be used here.
|
||||||
| `cwd` | :-1: | Sets the Current Working Directory (CWD) for `cmd`. Defaults to the directory of `cmd`. |
|
| `cwd` | :-1: | Sets the Current Working Directory (CWD) for `cmd`. Defaults to the directory of `cmd`. |
|
||||||
|
|
Loading…
Reference in New Issue