mirror of
https://github.com/yuzu-emu/Command-fix.git
synced 2024-12-22 18:05:26 +00:00
tree-wide: make sources more bundler friendly
This commit is contained in:
parent
e46432ac22
commit
4f8bf4574f
18
src/data.ts
18
src/data.ts
|
@ -1,6 +1,12 @@
|
|||
import * as fs from 'fs';
|
||||
import state from './state';
|
||||
import logger from './logging';
|
||||
import { IResponses } from './models/interfaces';
|
||||
|
||||
const responses: { [index: string]: IResponses } = {
|
||||
citra: require('./responses/citra.json'),
|
||||
yuzu: require('./responses/yuzu.json')
|
||||
};
|
||||
|
||||
export function readWarnings () {
|
||||
// Load the warnings file into the application state.
|
||||
|
@ -32,12 +38,14 @@ export function readBans () {
|
|||
|
||||
export function readCustomResponses () {
|
||||
// Load the responses file into the responses variable.
|
||||
try {
|
||||
state.responses = require(`./responses/${process.env.TENANT}.json`);
|
||||
logger.debug(`Loaded responses file for ${process.env.TENANT} from external source.`);
|
||||
} catch (e) {
|
||||
logger.error(`Failed to load ${process.env.TENANT}.json! Custom responses are disabled.`);
|
||||
if (process.env.TENANT) {
|
||||
state.responses = responses[process.env.TENANT];
|
||||
if (state.responses) {
|
||||
logger.debug(`Loaded responses file for ${process.env.TENANT} from external source.`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
logger.error(`Failed to load ${process.env.TENANT}.json! Custom responses are disabled.`);
|
||||
}
|
||||
|
||||
export function flushWarnings () {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import * as winston from 'winston';
|
||||
import * as ip from 'ip';
|
||||
import * as os from 'os';
|
||||
import LogdnaWinston from 'logdna-winston';
|
||||
|
||||
const logger = winston.createLogger({
|
||||
level: 'debug',
|
||||
|
@ -18,10 +19,9 @@ const logger = winston.createLogger({
|
|||
|
||||
// Setup logging for LogDNA cloud logging.
|
||||
if (process.env.LOGDNA_API_KEY) {
|
||||
const logdnaWinston = require('logdna-winston');
|
||||
const logLevel = process.env.LOGDNA_LEVEL || 'info';
|
||||
|
||||
logger.add(new logdnaWinston({
|
||||
logger.add(new LogdnaWinston({
|
||||
level: logLevel,
|
||||
app: process.env.LOGDNA_APPNAME,
|
||||
index_meta: true,
|
||||
|
|
|
@ -9,7 +9,9 @@ import triggers from './triggers/_';
|
|||
|
||||
// Check for environmental variables.
|
||||
import * as checkenv from 'checkenv';
|
||||
checkenv.setConfig(require('../env.json'));
|
||||
import envConfig from '../env.json';
|
||||
|
||||
checkenv.setConfig(envConfig);
|
||||
checkenv.check();
|
||||
|
||||
interface IModuleMap {
|
||||
|
@ -31,11 +33,11 @@ if (!rulesRole) {
|
|||
throw new Error('DISCORD_RULES_ROLE somehow became undefined.');
|
||||
}
|
||||
|
||||
function findArray(haystack: string | string[], arr: string[]) {
|
||||
function findArray (haystack: string | string[], arr: string[]) {
|
||||
return arr.some((v: string) => haystack.indexOf(v) >= 0);
|
||||
}
|
||||
|
||||
function IsIgnoredCategory(categoryName: string) {
|
||||
function IsIgnoredCategory (categoryName: string) {
|
||||
const IgnoredCategory = ['internal', 'team', 'development'];
|
||||
return IgnoredCategory.includes(categoryName);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue