forked from CarlosMarruedo/help-me-find-my-credentials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
30 lines (21 loc) · 658 Bytes
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var fs = require('fs');
var dirTree = require('directory-tree');
var indexer = require('./search/index-documents');
var rootDir = './public/src/';
var examplesJSON = './public/examples.json';
var filteredTree = dirTree(rootDir, { extensions: /\.(js|json)$/ });
indexer.index(filteredTree);
filteredTree = JSON.stringify(filteredTree, null, 2);
filteredTree = filteredTree.replace(/public\//g, '');
filteredTree = filteredTree.replace(/public\\\\/g, '');
// Save the JSON
fs.writeFile(examplesJSON, filteredTree, function (error) {
if (error)
{
throw error;
}
else
{
console.log('examples.json saved');
}
});