mirror of
https://forge.chapril.org/tykayn/wololo
synced 2025-10-04 17:04:53 +02:00
réinit
This commit is contained in:
commit
996524bc6d
107 changed files with 1295536 additions and 0 deletions
78
mappings/utils.ts
Normal file
78
mappings/utils.ts
Normal file
|
@ -0,0 +1,78 @@
|
|||
import * as fs from 'node:fs'
|
||||
|
||||
let show_debug = 0
|
||||
// show_debug = 1
|
||||
let output_folder = 'output';
|
||||
const prefix_phone_fr_only = true
|
||||
|
||||
// console.log('----------------------show_debug', show_debug)
|
||||
|
||||
/**
|
||||
* wrapper de log qui se montre uniquemnt si show_debug a été activé
|
||||
* @param args
|
||||
*/
|
||||
function debugLog(...args: any[]) {
|
||||
if (show_debug) {
|
||||
console.log('### debug: ',)
|
||||
args.map((elem: any) => console.log(' ', elem))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let 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: string): boolean {
|
||||
|
||||
return listOfBooleanKeys.indexOf(pointKeyName) !== -1
|
||||
}
|
||||
|
||||
/**
|
||||
* crée un fichier dans le dossier par défaut, output
|
||||
* @param fileName
|
||||
* @param fileContent
|
||||
*/
|
||||
function writeFile(fileName: string, fileContent: any, outputPathOverride: string = '') {
|
||||
|
||||
if (outputPathOverride) {
|
||||
output_folder = outputPathOverride
|
||||
} else {
|
||||
console.log('pas de output', outputPathOverride
|
||||
)
|
||||
}
|
||||
let destination = `./${output_folder}/${fileName}`.replace('//', '/');
|
||||
console.log('write file ', destination)
|
||||
return fs.writeFile(
|
||||
destination,
|
||||
fileContent,
|
||||
'utf8',
|
||||
(err) => {
|
||||
if (err) {
|
||||
console.log(`Error writing file: ${err}`)
|
||||
} else {
|
||||
console.log(`File ${fileName} is written successfully!`)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export default {
|
||||
debugLog,
|
||||
isBooleanKey,
|
||||
writeFile,
|
||||
prefix_phone_fr_only
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue