var request = require('request'),fs = require('fs'),colors = require('colors'); | |
var url = "http://KLRICE:klrice@localhost:9090/ords/klrice/_/sql" | |
// loop args 0="node" 1="compile" 2...= files to send | |
for (var i = 2; i < process.argv.length; i++) { | |
fs.createReadStream(process.argv[i]).pipe(request.post({ | |
url : url, | |
proxy:'', | |
method: 'POST', | |
time:true, | |
headers : {"Content-Type":"application/sql"}, | |
}, results)) | |
} | |
function results(error,response,body){ | |
console.log("Elapsed time:"+response.elapsedTime + "ms") | |
JSON.parse(body).items.forEach(function (e){ | |
console.log( e.statementType.bold +">>"+ e.statementText.substring(0,50).replace(/\n/g," ")+"..." ) | |
e.response.forEach(function(val,index,array){ | |
var hasError = /^(ERROR|PLS-|PLW-|ORA-|invalid)/.test(val); | |
console.log( (hasError?val.red:val) ) | |
}) | |
}) | |
} | |
/* | |
VSCode Task | |
{ | |
"version": "2.0.0", | |
"tasks": [ | |
{ | |
"label": "compile to ORDS-SQL", | |
"type": "shell", | |
"command": "node /Users/klrice/sql/compile ${file}", | |
"group": { | |
"kind": "build", | |
"isDefault": true | |
} | |
} | |
] | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment