Passed
Push — master ( 6b3293...e73aee )
by Sergii
01:30
created

module.exports   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
c 1
b 1
f 0
nc 1
nop 1
dl 0
loc 5
rs 9.4285
1
/**
2
 * @author Donii Sergii <[email protected]>
3
 */
4
const Handlebars = require('handlebars')
5
const fs = require('fs')
6
const path = require('path')
7
const beautify = require('js-beautify').js_beautify
8
const apiTemplate = fs.readFileSync(path.join(__dirname, '/../../../js-template/api.hbs'), 'utf-8')
9
const methods = fs.readFileSync(path.join(__dirname, '/../../../js-template/methods.hbs'), 'utf-8')
10
const method = fs.readFileSync(path.join(__dirname, '/../../../js-template/method.hbs'), 'utf-8')
11
Handlebars.registerPartial('methods', methods)
12
Handlebars.registerPartial('method', method)
13
Handlebars.registerHelper('toLowerCase', function (word) {
14
    return word.toLowerCase()
15
})
16
Handlebars.registerHelper('brackets', function (word) {
17
    return `{${word}}`
18
})
19
module.exports = function (data) {
20
    let template = Handlebars.compile(apiTemplate)(data)
21
    template = beautify(template, {indent_size: 2, max_preserve_newlines: -1})
22
    return template
23
}