mirror of
https://github.com/danbulant/sql2csv
synced 2026-05-19 04:18:33 +00:00
Better formatting
This commit is contained in:
parent
a912fde338
commit
b57793b58a
1 changed files with 9 additions and 2 deletions
11
sql2csv.js
11
sql2csv.js
|
|
@ -3,8 +3,11 @@ const { execSync } = require('child_process');
|
||||||
class sql2csv {
|
class sql2csv {
|
||||||
log(str){
|
log(str){
|
||||||
if(!this.options.logging) return;
|
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");
|
console.log(this.options.prefix + str + "\x1b[0m");
|
||||||
}
|
}
|
||||||
|
|
||||||
warn(str){
|
warn(str){
|
||||||
if(!this.options.logging) return;
|
if(!this.options.logging) return;
|
||||||
console.warn(this.options.prefix + "\x1b[33m" + str + "\x1b[0m");
|
console.warn(this.options.prefix + "\x1b[33m" + str + "\x1b[0m");
|
||||||
|
|
@ -15,11 +18,12 @@ class sql2csv {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
if(this.options.conn) this.conn = this.options.conn;
|
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.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 {
|
} else {
|
||||||
this.options = {};
|
this.options = {};
|
||||||
}
|
}
|
||||||
|
if(!this.options.prefix) this.options.prefix = "[SQL2CSV] ";
|
||||||
|
if(this.options.colors == undefined) this.options.colors = true;
|
||||||
|
|
||||||
if(!this.options.skipMysqlCheck){
|
if(!this.options.skipMysqlCheck){
|
||||||
try {
|
try {
|
||||||
this.log("Checking for mysql driver...");
|
this.log("Checking for mysql driver...");
|
||||||
|
|
@ -34,14 +38,17 @@ class sql2csv {
|
||||||
}
|
}
|
||||||
this.log("\x1b[32mInitialized");
|
this.log("\x1b[32mInitialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
//update certain option
|
//update certain option
|
||||||
setOption(name, value){
|
setOption(name, value){
|
||||||
this.options[name] = value;
|
this.options[name] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//overwrites options
|
//overwrites options
|
||||||
setOptions(options){
|
setOptions(options){
|
||||||
this.options = options;
|
this.options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
//set connection
|
//set connection
|
||||||
setConnection(conn){
|
setConnection(conn){
|
||||||
this.conn = conn;
|
this.conn = conn;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue