Passed
Push — master ( 2fc875...74c3e1 )
by André
45s
created

replaceTextFileString.js ➔ ???   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 10
nc 3
dl 0
loc 19
c 1
b 0
f 0
rs 9.9
nop 2
1
'use strict'
2
3
const fs = require('fs')
4
5
module.exports = (baseFileDir, value) => {
6
    if ( typeof(value
7
    ) != 'object' ) {
8
        return value
9
    }
10
11
    let filePath = baseFileDir + '/' + value.file
12
    let fileContent
13
14
    //try {
15
    fileContent = fs.readFileSync(filePath, 'utf-8')
16
    //} catch(error) {
17
    //    fileContent = '--Error loading file--';
18
    //}
19
20
    return value.text
21
        ? value.text.replace('$FILE', fileContent)
22
        : fileContent
23
}
24