62 lines
1.2 KiB
TypeScript
62 lines
1.2 KiB
TypeScript
import fs from 'node-fs'
|
|
|
|
let show_debug = 0
|
|
show_debug = 1
|
|
|
|
/**
|
|
* faire un log
|
|
* @param message
|
|
*/
|
|
function debugLog(...args : any) {
|
|
if (!show_debug) {
|
|
return
|
|
}
|
|
console.log('debug: ', ...args)
|
|
}
|
|
|
|
|
|
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
|
|
}
|
|
|
|
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!`)
|
|
}
|
|
}
|
|
)
|
|
}
|
|
|
|
export default {
|
|
debugLog,
|
|
isBooleanKey,
|
|
writeFile
|
|
}
|