1 | |||
2 | 1 | var fs = require('fs'); |
|
3 | 1 | var glob = require('glob'); |
|
4 | 1 | var globAll = require('glob-all'); |
|
5 | 1 | var path = require('path'); |
|
6 | 1 | var extend = require('util')._extend; |
|
7 | 1 | var format = require('string-template'); |
|
8 | 1 | var frontMatter = require('front-matter'); |
|
9 | |||
10 | 1 | module.exports = function(value, config, cb, pl) { |
|
11 | 2 | var data = getChangeLog (value, config, pl); |
|
12 | 2 | cb(null, processTree(data)); |
|
13 | } |
||
14 | |||
15 | 1 | module.exports.config = { |
|
16 | verbose: false |
||
17 | } |
||
18 | |||
19 | 1 | module.exports.search = function(items, link) { |
|
20 | 1 | var results = []; |
|
21 | // this => collider |
||
22 | /* results.push({ |
||
23 | name: name, |
||
24 | type: 'sass ' + type, |
||
25 | description: description, |
||
26 | link: link + hash |
||
27 | }); */ |
||
28 | |||
29 | 1 | return results; |
|
30 | } |
||
31 | |||
32 | |||
33 | function getChangeLog(value, config, pl) { |
||
34 | 2 | if (!fs.existsSync(value)) return false; |
|
0 ignored issues
–
show
|
|||
35 | 1 | var changelogFile = frontMatter(fs.readFileSync(value).toString()); |
|
36 | 1 | var srcTemplate = ''+changelogFile.body+''; |
|
37 | 1 | var result = pl.markdown.render(srcTemplate); |
|
38 | 1 | return result; |
|
39 | } |
||
40 | |||
41 | |||
42 | function processTree(tree) { |
||
43 | |||
44 | // ... my tree assignment stuff |
||
45 | |||
46 | 2 | return tree; //my_stuff; |
|
47 | } |
||
48 | |||
49 |
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.
Consider:
If you or someone else later decides to put another statement in, only the first statement will be executed.
In this case the statement
b = 42
will always be executed, while the logging statement will be executed conditionally.ensures that the proper code will be executed conditionally no matter how many statements are added or removed.