69 lines
1.8 KiB
JavaScript
69 lines
1.8 KiB
JavaScript
"use strict";
|
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
if (ar || !(i in from)) {
|
|
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
ar[i] = from[i];
|
|
}
|
|
}
|
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var fs_1 = require("fs");
|
|
var show_debug = 0;
|
|
show_debug = 1;
|
|
var output_folder = 'output';
|
|
/**
|
|
* wrapper de log qui se montre uniquemnt si show_debug a été activé
|
|
* @param args
|
|
*/
|
|
function debugLog() {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
if (!show_debug) {
|
|
return;
|
|
}
|
|
console.log.apply(console, __spreadArray(['debug: '], args, false));
|
|
}
|
|
var listOfBooleanKeys = [
|
|
"prise_type_ef",
|
|
"prise_type_2",
|
|
"prise_type_combo_ccs",
|
|
"prise_type_chademo",
|
|
"gratuit",
|
|
"paiement_acte",
|
|
"paiement_cb",
|
|
"cable_t2_attache"
|
|
];
|
|
/**
|
|
*
|
|
* @param pointKeyName
|
|
* @returns {boolean}
|
|
*/
|
|
function isBooleanKey(pointKeyName) {
|
|
return listOfBooleanKeys.indexOf(pointKeyName) !== -1;
|
|
}
|
|
/**
|
|
* crée un fichier dans le dossier par défaut, output
|
|
* @param fileName
|
|
* @param fileContent
|
|
*/
|
|
function writeFile(fileName, fileContent) {
|
|
debugLog('write file ', fileName);
|
|
return fs_1.default.writeFile("./".concat(output_folder, "/").concat(fileName), fileContent, 'utf8', function (err) {
|
|
if (err) {
|
|
debugLog("Error writing file: ".concat(err));
|
|
}
|
|
else {
|
|
debugLog("File ".concat(fileName, " is written successfully!"));
|
|
}
|
|
});
|
|
}
|
|
exports.default = {
|
|
debugLog: debugLog,
|
|
isBooleanKey: isBooleanKey,
|
|
writeFile: writeFile
|
|
};
|