Better formatting

This commit is contained in:
danbulant 2019-09-28 14:31:05 +02:00
parent a912fde338
commit b57793b58a

View file

@ -3,8 +3,11 @@ const { execSync } = require('child_process');
class sql2csv {
log(str){
if(!this.options.logging) return;
if(this.options.colors)
console.log(this.options.prefix + str + "\x1b[0m");
console.log(this.options.prefix + str + "\x1b[0m");
}
warn(str){
if(!this.options.logging) return;
console.warn(this.options.prefix + "\x1b[33m" + str + "\x1b[0m");
@ -15,11 +18,12 @@ class sql2csv {
this.options = options;
if(this.options.conn) this.conn = this.options.conn;
if(this.options.connection) this.conn = this.options.connection;//long alias for conn
if(!this.options.prefix) this.options.prefix = "[SQL2CSV] ";
if(this.options.colors) this.options.colors = true;
} else {
this.options = {};
}
if(!this.options.prefix) this.options.prefix = "[SQL2CSV] ";
if(this.options.colors == undefined) this.options.colors = true;
if(!this.options.skipMysqlCheck){
try {
this.log("Checking for mysql driver...");
@ -34,14 +38,17 @@ class sql2csv {
}
this.log("\x1b[32mInitialized");
}
//update certain option
setOption(name, value){
this.options[name] = value;
}
//overwrites options
setOptions(options){
this.options = options;
}
//set connection
setConnection(conn){
this.conn = conn;