1 | 1 | var path = require('path'); |
|
2 | 1 | var jsonfile = require('jsonfile'); |
|
3 | |||
4 | /** |
||
5 | * updates the pattern-library JSON data-file |
||
6 | */ |
||
7 | function updateDataFile ( ) { |
||
8 | |||
9 | 25 | var _this = this, |
|
10 | 25 | patterns = this.data.patterns, |
|
11 | 25 | categories = this.data.categories, |
|
12 | 25 | destPath = path.join(this.options.dest, this.options.basepath) |
|
13 | ; |
||
14 | |||
15 | // complete library data |
||
16 | 25 | var file = path.join(destPath, 'patternlibrary.json'); |
|
17 | 25 | jsonfile.writeFileSync(file, this.data, {spaces: 4}); |
|
18 | |||
19 | 25 | if (this.options.nogui === false) { |
|
20 | |||
21 | // search data |
||
22 | this.options.pageRoot = path.join(this.options.basepath, ''); |
||
23 | this.buildsearch(path.join(destPath, 'search.json'), function() { |
||
24 | |||
25 | // pattern data |
||
26 | var file = path.join(destPath, 'patterns.json'); |
||
27 | jsonfile.writeFileSync(file, patterns, {spaces: 4}); |
||
28 | |||
29 | // categorie data |
||
30 | var file = path.join(destPath, 'categories.json'); |
||
0 ignored issues
–
show
|
|||
31 | jsonfile.writeFileSync(file, categories, {spaces: 4}); |
||
32 | |||
33 | }); |
||
34 | |||
35 | } |
||
36 | |||
37 | } |
||
38 | |||
39 | module.exports = updateDataFile; |
||
40 |
This check looks for variables that are declared in multiple lines. There may be several reasons for this.
In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.
If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.