src/replaceTextFileString.js   A
last analyzed

Complexity

Total Complexity 3
Complexity/F 3

Size

Lines of Code 23
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 0
wmc 3
eloc 12
nc 2
mnd 1
bc 2
fnc 1
dl 0
loc 23
bpm 2
cpm 3
noi 0
c 2
b 0
f 1
rs 10

1 Function

Rating   Name   Duplication   Size   Complexity  
A replaceTextFileString.js ➔ ??? 0 19 3
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