diff --git a/WHATSNEW.md b/WHATSNEW.md index c3910cd4..79ec152d 100644 --- a/WHATSNEW.md +++ b/WHATSNEW.md @@ -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. * 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]). +* `dropFileType` is now optional when launching doors with `abracadabra`. It can also be explicitly set to `none`. ## 0.0.11-beta * Upgraded from `alpha` to `beta` -- The software is far along and mature enough at this point! diff --git a/core/abracadabra.js b/core/abracadabra.js index 3f21fa0b..a8a72b1d 100644 --- a/core/abracadabra.js +++ b/core/abracadabra.js @@ -11,12 +11,14 @@ const { trackDoorRunBegin, trackDoorRunEnd } = require('./door_util.js'); +const Log = require('./logger').log; // deps const async = require('async'); const assert = require('assert'); const _ = require('lodash'); const paths = require('path'); +const fs = require('graceful-fs'); 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, ... } // .. and/or EnigAssert 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')); this.config.nodeMax = this.config.nodeMax || 0; 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() { if(activeDoorNodeInstances[this.config.name]) { activeDoorNodeInstances[this.config.name] += 1; @@ -141,11 +135,15 @@ exports.getModule = class AbracadabraModule extends MenuModule { return self.doorInstance.prepare(self.config.io || 'stdio', callback); }, function generateDropfile(callback) { - const dropFileOpts = { - fileType : self.config.dropFileType, - }; + if (!self.config.dropFileType || self.config.dropFileType.toLowerCase() === 'none') { + 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); } ], @@ -170,18 +168,30 @@ exports.getModule = class AbracadabraModule extends MenuModule { args : this.config.args, io : this.config.io || 'stdio', encoding : this.config.encoding || 'cp437', - dropFile : this.dropFile.fileName, - dropFilePath : this.dropFile.fullPath, node : this.client.node, 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); this.doorInstance.run(exeInfo, () => { trackDoorRunEnd(doorTracking); 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 - // we're done here if so. if(!this.client.term.output) { diff --git a/docs/modding/local-doors.md b/docs/modding/local-doors.md index ccd9a495..c52fc522 100644 --- a/docs/modding/local-doors.md +++ b/docs/modding/local-doors.md @@ -14,7 +14,7 @@ The `abracadabra` `config` block can contain the following members: | Item | Required | Description | |------|----------|-------------| | `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. | | `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`. |