1
0
Fork 0

fix conflict

refactor/models
Matthew 2020-05-05 19:41:56 -04:00
commit a5fefbd264
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
5 changed files with 42 additions and 31 deletions

View File

@ -29,7 +29,8 @@
"uuid": "^3.3.3" "uuid": "^3.3.3"
}, },
"devDependencies": { "devDependencies": {
"@types/express": "^4.17.2", "@types/express": "^4.17.6",
"@types/express-serve-static-core": "^4.17.5",
"@types/fs-extra": "^8.0.0", "@types/fs-extra": "^8.0.0",
"@types/helmet": "^0.0.45", "@types/helmet": "^0.0.45",
"@types/ioredis": "^4.0.18", "@types/ioredis": "^4.0.18",

View File

@ -70,7 +70,7 @@ export default class Security {
return req.headers.authorization.split(' ')[1]; return req.headers.authorization.split(' ')[1];
} }
if (req.query && req.query.token) { if (req.query && req.query.token) {
return req.query.token; return req.query.token as string;
} }
return '0000000000'; return '0000000000';
} }

View File

@ -32,15 +32,25 @@ export default class Util {
* @param options childProcess.ExecOptions * @param options childProcess.ExecOptions
*/ */
public async exec(command: string, options: childProcess.ExecOptions = {}): Promise<string> { public async exec(command: string, options: childProcess.ExecOptions = {}): Promise<string> {
const ex = promisify(childProcess.exec); return new Promise((res, rej) => {
let result: string; let error = false;
try { let output = '';
const res = await ex(command, options); const writeFunction = (data: string|Buffer|Error) => {
result = `${res.stdout}${res.stderr}`; if (data instanceof Error) error = true;
} catch (err) { output += `${data}`;
return Promise.reject(new Error(`Command failed: ${err.cmd}\n${err.stderr}${err.stdout}`)); };
} const cmd = childProcess.exec(command, options);
return result; cmd.stdout.on('data', writeFunction);
cmd.stderr.on('data', writeFunction);
cmd.on('error', writeFunction);
cmd.once('close', (code, signal) => {
cmd.stdout.removeListener('data', writeFunction);
cmd.stderr.removeListener('data', writeFunction);
cmd.removeListener('error', writeFunction);
if (error) rej(output);
res(output);
});
});
} }
/** /**

View File

@ -32,7 +32,7 @@ export default class Load extends Command {
delete require.cache[`${corepath}/commands/index.js`]; delete require.cache[`${corepath}/commands/index.js`];
delete require.cache[`${corepath}/commands/${args[1]}.js`]; delete require.cache[`${corepath}/commands/${args[1]}.js`];
Object.keys(require.cache).filter((path) => path.includes(`${args[1]}_`)).forEach((path) => delete require.cache[path]); Object.keys(require.cache).filter((path) => path.includes(`${args[1]}_`)).forEach((path) => delete require.cache[path]);
const cmdIndex = require('../commands'); const cmdIndex = require('.');
let Cmd = cmdIndex[args[1]]; let Cmd = cmdIndex[args[1]];
if (!Cmd) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Could not find file***`); if (!Cmd) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Could not find file***`);
Cmd = require(`${corepath}/commands/${args[1]}`).default; Cmd = require(`${corepath}/commands/${args[1]}`).default;