diff --git a/bin/txt-to-sql-run.js b/bin/txt-to-sql-run.js index 40fcc73..fa7ae8f 100644 --- a/bin/txt-to-sql-run.js +++ b/bin/txt-to-sql-run.js @@ -8,6 +8,7 @@ var Promises = require('best-promise'); var fs = require('fs-promise'); var fsSync = require('fs'); var Path = require('path'); +var miniTools = require('mini-tools'); var jsYaml = require('js-yaml'); var changing = require('best-globals').changing; var readline = require('readline'); @@ -49,6 +50,17 @@ cmdParams.exportDefaults = program.exportDefaults; // numero de lineas a leer para analizar entrada var bufferingThreeshold = 50; +function readConfigData(configFile) { + return Promises.start(function() { + return fs.exists(configFile); + }).then(function(exists) { + if(exists) { + return miniTools.readConfig([configFile]); + } + return {invalid:true}; + }); +}; + function createParams(params, preparedParams) { var res = { tableName:params.tableName, @@ -219,10 +231,10 @@ getOutputDir(cmdParams.input).then(function(dir) { var inputBase = Path.resolve(dir, inputName); var inputYaml = inputBase+'.yaml'; var createInputYaml = false; - return txtToSql.readConfigData(inputYaml).then(function(data) { + return readConfigData(inputYaml).then(function(data) { if(data.invalid) { createInputYaml = true; - return txtToSql.readConfigData(inputBase+'.json'); + return readConfigData(inputBase+'.json'); } return data; }).then(function(data) { diff --git a/lib/txt-to-sql-defaults.yaml b/lib/txt-to-sql-defaults.yaml index 881f0f3..4e611e9 100644 --- a/lib/txt-to-sql-defaults.yaml +++ b/lib/txt-to-sql-defaults.yaml @@ -1,11 +1,11 @@ - columnNamesFormat: lowercased_names - separator: false - includePrimaryKey: true - columnAlignedCommas: false - columnAlignedMaxWidth: 100 - outputEngine: postgresql - verboseErrors: false - inputEncoding: false - outputEncoding: false - addDropTable: false - ignoreNullLines: false \ No newline at end of file +columnNamesFormat: lowercased_names +separator: false +includePrimaryKey: true +columnAlignedCommas: false +columnAlignedMaxWidth: 100 +outputEngine: postgresql +verboseErrors: false +inputEncoding: false +outputEncoding: false +addDropTable: false +ignoreNullLines: false diff --git a/lib/txt-to-sql.js b/lib/txt-to-sql.js index b680682..36fd7c3 100644 --- a/lib/txt-to-sql.js +++ b/lib/txt-to-sql.js @@ -4,9 +4,6 @@ var txtToSql = {}; var changing = require('best-globals').changing; var iconv = require('iconv-lite'); -var miniTools = require('mini-tools'); -var Promises = require('best-promise'); -var fs = require('fs-promise'); var margin = ' '; var separators=';,\t|'; @@ -37,16 +34,6 @@ if (typeof Object.assign != 'function') { })(); } -function readConfigData(configFile) { - return Promises.start(function() { - return fs.exists(configFile); - }).then(function(exists) { - if(exists) { - return miniTools.readConfig([configFile]); - } - return {invalid:true}; - }); -}; function adaptPlain(x){ if(x===''){ return 'null'; } @@ -75,10 +62,10 @@ function mapTypes(typeNames) { return typeNames.map(function(type, index) { return Object.assign({typeName:type}, types[index]); }); } -function quoteBackTick(objectName) { return '`'+objectName.replace(/`/g,'``')+'`'; } +function quoteBackTick(objectName) { return '`'+objectName.replace(/`/g,'``')+'`'; }; // Solo hay que escapar ']' de acuerdo con: https://technet.microsoft.com/en-us/library/ms176027(v=sql.105).aspx -function quoteBracket(objectName) { return '['+objectName.replace(/]/g,']]')+']'; } -function quoteDouble(objectName) { return '"'+objectName.replace(/"/g,'""')+'"'; } +function quoteBracket(objectName) { return '['+objectName.replace(/]/g,']]')+']'; }; +function quoteDouble(objectName) { return '"'+objectName.replace(/"/g,'""')+'"'; }; function dropTableIfExists(tableName) { return "drop table if exists "+tableName; } function dropTable(tableName) { return "drop table "+tableName; } @@ -121,7 +108,6 @@ function throwIfErrors(errors) { } } -/* txtToSql.defaultOpts = { columnNamesFormat: 'lowercased_names', separator: false, @@ -135,7 +121,6 @@ txtToSql.defaultOpts = { addDropTable: false, ignoreNullLines: false }; -*/ var letterTranslator = { 'à':'a', 'á':'a', 'â':'a', 'ã':'a', 'ä':'a', 'å':'a', 'À':'a', 'Á':'a', 'Â':'a', 'Ã':'a', 'Ä':'a', 'Å':'a', @@ -165,14 +150,6 @@ function checkEncodingParam(encoding, inOrOut, errors) { } } -function readDefaults(info) { - return readConfigData('./lib/txt-to-sql-defaults.yaml').then(function(data) { - if(data.invalid) { throw new Error('default config file not found'); } - txtToSql.defaultOpts = data; - return info; - }); -} - function verifyInputParams(info){ info.opts = changing(txtToSql.defaultOpts, info.opts || {}); var errors=[]; @@ -570,7 +547,6 @@ function processOutputBuffer(info) { function setup(info) { return Promise.resolve(info) - .then(readDefaults) .then(verifyInputParams) .then(processEncodingOptions) .then(separateLines) @@ -649,6 +625,5 @@ txtToSql.createAdaptedRows = createAdaptedRows; txtToSql.createInsertInto = createInsertInto; txtToSql.createInsertValues = createInsertValues; txtToSql.generatePrepareResult = generatePrepareResult; -txtToSql.readConfigData = readConfigData; module.exports = txtToSql; \ No newline at end of file diff --git a/package.json b/package.json index c0799e3..6685d88 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "start": "node example/server.js", + "defyaml": "node tools/defyaml.js && git add lib", "web": "node tools/web.js && git add web", "lint": "jshint .", "validate": "npm ls" @@ -56,6 +57,7 @@ "type": "web" }, "pre-commit": [ + "defyaml", "web" ] } \ No newline at end of file diff --git a/tools/defyaml.js b/tools/defyaml.js new file mode 100644 index 0000000..0054f1a --- /dev/null +++ b/tools/defyaml.js @@ -0,0 +1,22 @@ +"use strict"; + +var txtToSql = require('../lib/txt-to-sql.js'); +var jsYaml = require('js-yaml'); +var Promises = require('best-promise'); +require('fs-extra'); +var fs = require('fs-promise'); + +var Path = require('path'); + +function createDefaultYaml() { + var defaultYaml = Path.resolve('./lib/txt-to-sql-defaults.yaml'); + console.log("Generating '"+defaultYaml+"'..."); + return fs.writeFile(defaultYaml, jsYaml.safeDump(txtToSql.defaultOpts), {encoding:'utf8'}).then(function() { + console.log("listo.") + }).catch(function(err) { + console.log("Error", err, err.stack); + process.exit(1); + }); +} + +createDefaultYaml(); diff --git a/tools/web.js b/tools/web.js index 512aaa9..ad40a17 100644 --- a/tools/web.js +++ b/tools/web.js @@ -75,11 +75,11 @@ function generateWeb() { console.log("Generating web content..."); var desDir = './web'; return processDirectory('./src', desDir).then(function() { - return processDirectory('./lib', desDir); + return processDirectory('./lib', desDir, ['js']); }).then(function() { return fs.copy('./node_modules/best-globals/best-globals.js', desDir+'/best-globals.js'); - // }).then(function() { - // return processDirectory('./node_modules/best-promise', desDir, ['js']); + //}).then(function() { + // return processDirectory('./node_modules/best-promise', desDir, ['js']); }).then(function() { return processDirectory('./node_modules/require-bro/lib', desDir); }).then(function() { @@ -98,6 +98,8 @@ function generateWeb() { return bundlePromise(b); }).then(function(bfbuf) { return fs.writeFile(desDir+'/buffer.js', bfbuf); + // }).then(function() { + // return fs.copy('./node_modules/mini-tools/lib/mini-tools.js', desDir+'/mini-tools.js'); }).catch(function(err) { console.log("Error", err, err.stack); process.exit(1); diff --git a/web/buffer.js b/web/buffer.js index 9ec479c..d5ad38b 100644 --- a/web/buffer.js +++ b/web/buffer.js @@ -1,208 +1,4 @@ -require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 - - // base64 is 4/3 + up to two characters of the original data - arr = new Arr(len * 3 / 4 - placeHolders) - - // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? len - 4 : len - - var L = 0 - - for (i = 0, j = 0; i < l; i += 4, j += 3) { - tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] - arr[L++] = (tmp >> 16) & 0xFF - arr[L++] = (tmp >> 8) & 0xFF - arr[L++] = tmp & 0xFF - } - - if (placeHolders === 2) { - tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) - arr[L++] = tmp & 0xFF - } else if (placeHolders === 1) { - tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) - arr[L++] = (tmp >> 8) & 0xFF - arr[L++] = tmp & 0xFF - } - - return arr -} - -function tripletToBase64 (num) { - return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] -} - -function encodeChunk (uint8, start, end) { - var tmp - var output = [] - for (var i = start; i < end; i += 3) { - tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) - output.push(tripletToBase64(tmp)) - } - return output.join('') -} - -function fromByteArray (uint8) { - var tmp - var len = uint8.length - var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes - var output = '' - var parts = [] - var maxChunkLength = 16383 // must be multiple of 3 - - // go through the array every three bytes, we'll deal with trailing stuff later - for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) - } - - // pad the end with zeros, but make sure to not forget the extra bytes - if (extraBytes === 1) { - tmp = uint8[len - 1] - output += lookup[tmp >> 2] - output += lookup[(tmp << 4) & 0x3F] - output += '==' - } else if (extraBytes === 2) { - tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) - output += lookup[tmp >> 10] - output += lookup[(tmp >> 4) & 0x3F] - output += lookup[(tmp << 2) & 0x3F] - output += '=' - } - - parts.push(output) - - return parts.join('') -} - -},{}],2:[function(require,module,exports){ -exports.read = function (buffer, offset, isLE, mLen, nBytes) { - var e, m - var eLen = nBytes * 8 - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var nBits = -7 - var i = isLE ? (nBytes - 1) : 0 - var d = isLE ? -1 : 1 - var s = buffer[offset + i] - - i += d - - e = s & ((1 << (-nBits)) - 1) - s >>= (-nBits) - nBits += eLen - for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} - - m = e & ((1 << (-nBits)) - 1) - e >>= (-nBits) - nBits += mLen - for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} - - if (e === 0) { - e = 1 - eBias - } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity) - } else { - m = m + Math.pow(2, mLen) - e = e - eBias - } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen) -} - -exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c - var eLen = nBytes * 8 - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) - var i = isLE ? 0 : (nBytes - 1) - var d = isLE ? 1 : -1 - var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 - - value = Math.abs(value) - - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0 - e = eMax - } else { - e = Math.floor(Math.log(value) / Math.LN2) - if (value * (c = Math.pow(2, -e)) < 1) { - e-- - c *= 2 - } - if (e + eBias >= 1) { - value += rt / c - } else { - value += rt * Math.pow(2, 1 - eBias) - } - if (value * c >= 2) { - e++ - c /= 2 - } - - if (e + eBias >= eMax) { - m = 0 - e = eMax - } else if (e + eBias >= 1) { - m = (value * c - 1) * Math.pow(2, mLen) - e = e + eBias - } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) - e = 0 - } - } - - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} - - e = (e << mLen) | m - eLen += mLen - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} - - buffer[offset + i - d] |= s * 128 -} - -},{}],3:[function(require,module,exports){ -var toString = {}.toString; - -module.exports = Array.isArray || function (arr) { - return toString.call(arr) == '[object Array]'; -}; - -},{}],"buffer":[function(require,module,exports){ +require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 + + // base64 is 4/3 + up to two characters of the original data + arr = new Arr(len * 3 / 4 - placeHolders) + + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? len - 4 : len + + var L = 0 + + for (i = 0, j = 0; i < l; i += 4, j += 3) { + tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] + arr[L++] = (tmp >> 16) & 0xFF + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } + + if (placeHolders === 2) { + tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[L++] = tmp & 0xFF + } else if (placeHolders === 1) { + tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } + + return arr +} + +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] +} + +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) + output.push(tripletToBase64(tmp)) + } + return output.join('') +} + +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var output = '' + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + output += lookup[tmp >> 2] + output += lookup[(tmp << 4) & 0x3F] + output += '==' + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) + output += lookup[tmp >> 10] + output += lookup[(tmp >> 4) & 0x3F] + output += lookup[(tmp << 2) & 0x3F] + output += '=' + } + + parts.push(output) + + return parts.join('') +} + +},{}],2:[function(require,module,exports){ +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen) + e = e - eBias + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +} + +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + + value = Math.abs(value) + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } + + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = (value * c - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128 +} + +},{}],3:[function(require,module,exports){ +var toString = {}.toString; + +module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; + +},{}]},{},[]); diff --git a/web/txt-to-sql-defaults.yaml b/web/txt-to-sql-defaults.yaml deleted file mode 100644 index 881f0f3..0000000 --- a/web/txt-to-sql-defaults.yaml +++ /dev/null @@ -1,11 +0,0 @@ - columnNamesFormat: lowercased_names - separator: false - includePrimaryKey: true - columnAlignedCommas: false - columnAlignedMaxWidth: 100 - outputEngine: postgresql - verboseErrors: false - inputEncoding: false - outputEncoding: false - addDropTable: false - ignoreNullLines: false \ No newline at end of file diff --git a/web/txt-to-sql.js b/web/txt-to-sql.js index b680682..36fd7c3 100644 --- a/web/txt-to-sql.js +++ b/web/txt-to-sql.js @@ -4,9 +4,6 @@ var txtToSql = {}; var changing = require('best-globals').changing; var iconv = require('iconv-lite'); -var miniTools = require('mini-tools'); -var Promises = require('best-promise'); -var fs = require('fs-promise'); var margin = ' '; var separators=';,\t|'; @@ -37,16 +34,6 @@ if (typeof Object.assign != 'function') { })(); } -function readConfigData(configFile) { - return Promises.start(function() { - return fs.exists(configFile); - }).then(function(exists) { - if(exists) { - return miniTools.readConfig([configFile]); - } - return {invalid:true}; - }); -}; function adaptPlain(x){ if(x===''){ return 'null'; } @@ -75,10 +62,10 @@ function mapTypes(typeNames) { return typeNames.map(function(type, index) { return Object.assign({typeName:type}, types[index]); }); } -function quoteBackTick(objectName) { return '`'+objectName.replace(/`/g,'``')+'`'; } +function quoteBackTick(objectName) { return '`'+objectName.replace(/`/g,'``')+'`'; }; // Solo hay que escapar ']' de acuerdo con: https://technet.microsoft.com/en-us/library/ms176027(v=sql.105).aspx -function quoteBracket(objectName) { return '['+objectName.replace(/]/g,']]')+']'; } -function quoteDouble(objectName) { return '"'+objectName.replace(/"/g,'""')+'"'; } +function quoteBracket(objectName) { return '['+objectName.replace(/]/g,']]')+']'; }; +function quoteDouble(objectName) { return '"'+objectName.replace(/"/g,'""')+'"'; }; function dropTableIfExists(tableName) { return "drop table if exists "+tableName; } function dropTable(tableName) { return "drop table "+tableName; } @@ -121,7 +108,6 @@ function throwIfErrors(errors) { } } -/* txtToSql.defaultOpts = { columnNamesFormat: 'lowercased_names', separator: false, @@ -135,7 +121,6 @@ txtToSql.defaultOpts = { addDropTable: false, ignoreNullLines: false }; -*/ var letterTranslator = { 'à':'a', 'á':'a', 'â':'a', 'ã':'a', 'ä':'a', 'å':'a', 'À':'a', 'Á':'a', 'Â':'a', 'Ã':'a', 'Ä':'a', 'Å':'a', @@ -165,14 +150,6 @@ function checkEncodingParam(encoding, inOrOut, errors) { } } -function readDefaults(info) { - return readConfigData('./lib/txt-to-sql-defaults.yaml').then(function(data) { - if(data.invalid) { throw new Error('default config file not found'); } - txtToSql.defaultOpts = data; - return info; - }); -} - function verifyInputParams(info){ info.opts = changing(txtToSql.defaultOpts, info.opts || {}); var errors=[]; @@ -570,7 +547,6 @@ function processOutputBuffer(info) { function setup(info) { return Promise.resolve(info) - .then(readDefaults) .then(verifyInputParams) .then(processEncodingOptions) .then(separateLines) @@ -649,6 +625,5 @@ txtToSql.createAdaptedRows = createAdaptedRows; txtToSql.createInsertInto = createInsertInto; txtToSql.createInsertValues = createInsertValues; txtToSql.generatePrepareResult = generatePrepareResult; -txtToSql.readConfigData = readConfigData; module.exports = txtToSql; \ No newline at end of file