2023-07-31 19:27:17 +02:00
|
|
|
import fs from 'node-fs'
|
2023-07-30 18:37:07 +02:00
|
|
|
|
2023-07-31 19:27:17 +02:00
|
|
|
let show_debug = 1
|
2023-07-30 18:37:07 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* faire un log
|
|
|
|
* @param message
|
|
|
|
*/
|
|
|
|
function debugLog (message) {
|
|
|
|
if (!show_debug) {
|
|
|
|
return
|
|
|
|
}
|
2023-07-31 19:27:17 +02:00
|
|
|
console.log('debug: ', message)
|
2023-07-30 18:37:07 +02:00
|
|
|
}
|
2023-07-30 19:18:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
let listOfBooleanKeys = Object.keys({
|
|
|
|
prise_type_ef: 'socket:typee',
|
|
|
|
prise_type_2: 'socket:type2',
|
|
|
|
prise_type_combo_ccs: 'socket:type2_combo',
|
|
|
|
prise_type_chademo: 'socket:chademo',
|
|
|
|
gratuit: 'fee',
|
|
|
|
paiement_acte: 'authentication:none',
|
|
|
|
paiement_cb: 'payment:credit_cards',
|
|
|
|
cable_t2_attache: 'socket:type2_cable',
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param pointKeyName
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
function isBooleanKey(pointKeyName) {
|
|
|
|
|
|
|
|
return listOfBooleanKeys.indexOf(pointKeyName) !== -1
|
|
|
|
}
|
|
|
|
|
2023-07-31 19:27:17 +02:00
|
|
|
function writeFile (fileName, fileContent) {
|
|
|
|
debugLog('write file ', fileName)
|
|
|
|
|
|
|
|
return fs.writeFile(
|
|
|
|
`./output/${fileName}`,
|
|
|
|
fileContent,
|
|
|
|
'utf8',
|
|
|
|
(err) => {
|
|
|
|
if (err) {
|
|
|
|
debugLog(`Error writing file: ${err}`)
|
|
|
|
} else {
|
|
|
|
debugLog(`File ${fileName} is written successfully!`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
2023-07-30 18:37:07 +02:00
|
|
|
export default
|
|
|
|
{
|
2023-07-30 19:18:17 +02:00
|
|
|
debugLog,
|
2023-07-31 19:27:17 +02:00
|
|
|
isBooleanKey,
|
|
|
|
writeFile
|
2023-07-30 18:37:07 +02:00
|
|
|
}
|