Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var assert = require('assert')
var mockery = require('mockery')
var log = require('loglevel')
log.disableAll()
var param
var request = function (req) {
param = req
}
request.post = function (req) {
param = req
}
describe('Slackbot', function(){
before(function() {
mockery.enable({useCleanCache: true}); // Enable mockery at the start of your test suite
mockery.registerMock('request', request);
mockery.registerAllowables(['loglevel', 'events', '../../lib/slackbot.js', 'util']);
slackbot = require('../../lib/slackbot.js')
})
process.exit(1);
}
return result;
}, {});
await copyFiles(types, "types", {
message:
"Copying over the type definitions for the sassdoc package and the custom formatted sassdocs.",
replace: name =>
name
.replace("types", "formattedSassDoc")
.substring(name.indexOf("sassdoc/") + "sassdoc/".length),
});
log.info("Generating SassDoc files...");
await Promise.all(
Object.entries(combined).map(([name, formatted]) => {
const fileName = `${toTitle(name)}SassDoc`;
const filePath = path.join(
documentationRoot,
"constants",
`${fileName}.ts`
);
const contents = format(`/* this is a generated file and shouldn't be manually updated */
import { PackageSassDoc } from "types/formattedSassDoc.d";
const ${fileName}: PackageSassDoc = ${JSON.stringify(formatted)};
export default ${fileName};
`);
const qs = require("querystring");
const md5 = require("md5");
const youdao_zh_2_en = "zh-CHS2EN";
process.env.NODE_ENV = "production";
// process.env.NODE_ENV = "dev";
let isDev = require("isdev");
const Preview = require("./Preview.jsx").default;
console.log("isDev:", isDev);
if (isDev) {
log.setLevel("debug");
log.debug("in Development");
} else {
log.setLevel("silent");
console.log("Not in Development!");
}
var getKeyWordReg = function(key) {
return new RegExp(
"([\\-_\\w\\d\\/\\$]{0,}){0,1}" + key + "([\\-_\\w\\d\\$]{0,}){0,1}",
"gi"
);
};
var showing_display = [];
const youdaoapi_url = "http://openapi.youdao.com/api";
var searchcode_axios = axios.create({
// TODO: label template storage
// TODO: command chaining
// TODO: command wiring to label object
// TODO: label may also contain width/height (for continuous media)
program
.version('0.0.1')
.option('-c, --content <content>', 'label content as JSON')
.option('-j, --json ', 'JSON description of printing parameters')
.option('-v, --verbose', 'ouput useful information', (v, total) => (total === 0) ? 0 : total-1, 2)
.option('-t, --test', 'print a test label')
.option('-c, --check', 'dry-run; do not send label to printer')
.parse(process.argv);
console.log('loglevel: '+program.verbose);
log.setLevel(program.verbose);
var defaultPrinterModel = PRINTERS.ZEBRA_GX430T;
var defaultPrinter = Object.assign({
name: 'Default Printer',
address: '192.168.1.14'
}, defaultPrinterModel, program.json && program.json.printer);
var defaultMedia = {
width: 2 * 25.4,
length: 1 * 25.4,
// [thermal type]
// [thickness?]
// [price/label?]
// [spool size]
// [supply quantity]
// [model / reorder number?]
};</content>
)
parser.addArgument(
['--prune-months'], {
help: 'The amount of history (in number of months) to retain in Redshift',
type: 'int'
}
)
var args = parser.parseArgs()
if (args.debug) {
log.setLevel('debug')
log.debug('Debugging output enabled.')
} else {
log.setLevel('info')
}
log.debug(`Resolved invocation arguments were:\n${util.inspect(args)}`)
if (args.specific !== null && args.prune_months !== null) {
log.error('The "--specific" and "--prune-months" options are mutually exclusive.')
log.error('--prune-months can only be invoked when importing the latest DBR.')
log.error('Aborting.')
process.exit(1)
}
// Instantiate a DBR object to work with.
var dbrClientOptions = {
accessKeyId: args.source_key,
secretAccessKey: args.source_secret
}
var log = require('loglevel')
var validator = require('validator')
var errorHandlers = require('../common/errorHandlers')
var settings = require('../common/settings.js')
// Change this to alter how much information is printed out
log.setLevel('trace')
log.enableAll()
console.log('server.js: Starting server.js')
console.log('server.js: Will require db.js')
try {
var app = require('../common/microService.js')
var db = require('../common/db.js')(log)
// add query handler API
require('./serverApi.js')(app, db, log, validator) // configure our routes
// add test query handler API
require('../tester/testerApi.js')(app, db, log, validator) // configure our routes
// Set port to 8080
var port = settings.ETHEROSCOPESERVER.slice(-4)
define(function (require, exports, module) {
"use strict";
var loglevel = require("loglevel");
/*eslint no-console:0*/
if (__PG_DEBUG__) {
// If the debug global is set, log messages at and below debug level
loglevel.enableAll();
if (!loglevel.hasOwnProperty("table")) {
loglevel.table = console.table.bind(console);
}
} else {
// Otherwise, only log information, warnings and errors
loglevel.setLevel(loglevel.levels.INFO);
}
if (!loglevel.hasOwnProperty("timeStamp")) {
loglevel.timeStamp = console.timeStamp.bind(console);
}
module.exports = loglevel;
});
var fs = require('fs');
var util = require('util');
var moment = require('moment');
// #### logging decoration ####
// see https://github.com/kutuluk/loglevel-plugin-prefix
const colors = {
TRACE: chalk.magenta,
DEBUG: chalk.cyan,
INFO: chalk.blue,
WARN: chalk.yellow,
ERROR: chalk.red,
};
prefix.reg(log);
log.enableAll();
prefix.apply(log, {
format(level, name, timestamp) {
return `${chalk.gray(`[${timestamp}]`)} ${colors[level.toUpperCase()](level)} ${chalk.green(`${name}:`)}`;
},
});
const WRITE_LOG = true;
var logBuf = "";
function writeLog(callback) {
if (logBuf && WRITE_LOG) {
fs.appendFile("log/" + moment(new Date()).format("MM-DD"), logBuf, function(err) {
if (err) console.log("ERROR, could not write log to file log/" + moment(new Date()).format("MM-DD") + " : " + err);
if (callback) callback();
});
const loglevel = require('loglevel');
// -----------------------------------------------------------------------------
// Code
// -----------------------------------------------------------------------------
const colors = {
trace: '',
debug: '\x1b[90m',
info: '\x1b[94m',
warn: '\x1b[93m',
error: '\x1b[91m',
};
const originalFactory = loglevel.methodFactory;
loglevel.methodFactory = (methodName, logLevel, loggerName) => {
const rawMethod = originalFactory(methodName, logLevel, loggerName);
return message => {
// Getting stacktrace
const err = new Error();
const callerLine = err.stack.split('\n')[2];
let invokeLocation = callerLine.match(/\(\/.*\)/);
if (invokeLocation) {
// Removing () brackets around line and replace core folder
// where app is stored inside Docker container
invokeLocation = invokeLocation[0].slice(1, -1).replace('/opt/app', '');
} else {
invokeLocation = '';
}
let prefix = '';
const loglevel = require('loglevel');
// -----------------------------------------------------------------------------
// Code
// -----------------------------------------------------------------------------
const colors = {
trace: '',
debug: '\x1b[90m',
info: '\x1b[94m',
warn: '\x1b[93m',
error: '\x1b[91m',
};
const originalFactory = loglevel.methodFactory;
loglevel.methodFactory = (methodName, logLevel, loggerName) => {
const rawMethod = originalFactory(methodName, logLevel, loggerName);
return message => {
// Getting stacktrace
const err = new Error();
const callerLine = err.stack.split('\n')[2];
let invokeLocation = callerLine.match(/\(\/.*\)/);
if (invokeLocation) {
// Removing () brackets around line and replace core folder
// where app is stored inside Docker container
invokeLocation = invokeLocation[0].slice(1, -1).replace('/opt/app', '');
} else {
invokeLocation = '';
}
let prefix = '';
if (process.env.NODE_ENV === 'development') {