From 068bcc8087c7d95ebc8e45f1e7b8e930d7c8f944 Mon Sep 17 00:00:00 2001 From: Scar26 Date: Mon, 25 May 2020 21:03:21 +0530 Subject: [PATCH] Use absolute path for factory.js Signed-off-by: Scar26 --- index.js | 3 ++- test/factory.js | 33 --------------------------------- 2 files changed, 2 insertions(+), 34 deletions(-) delete mode 100644 test/factory.js diff --git a/index.js b/index.js index 6a71887..54d3224 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,7 @@ const { VM } = require('vm2') const fs = require('fs') -const ctx = fs.readFileSync('./factory.js').toString() +const path = require('path') // eslint-disable-line no-unused-vars +const ctx = fs.readFileSync(`${__dirname}/factory.js`).toString() class Bot { constructor (name, greeting, trainingSet) { diff --git a/test/factory.js b/test/factory.js deleted file mode 100644 index e4afadf..0000000 --- a/test/factory.js +++ /dev/null @@ -1,33 +0,0 @@ -/* eslint-disable no-unused-vars */ -var trainingSet -var responseSet - -var users = { - idmap: {}, - - addUser: function (token, name) { - this.idmap[token] = name - }, - - get: function (token) { - return this.idmap[token] - } -} - -function train () { - global.responseSet = global.trainingSet -} - -function process (query, token) { - if (users.get(token)) { - return { action: 'response', message: responseSet[query] } - } else { - return { action: 'unrecognized', message: 'user does not exist' } - } -} - -function currentUser (token) { - return users.idmap[token] -} - -/* eslint-enable no-unused-vars */