Skip to content

Commit b8994cd

Browse files
committed
Fix plugin with new structure of source.
1 parent ee31817 commit b8994cd

File tree

3 files changed

+65
-50
lines changed

3 files changed

+65
-50
lines changed

assets/css/specDependencies.css

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,46 @@
33
position: relative;
44
border-radius: 10px;
55
}
6-
.source_deps:empty {
7-
display: none;
8-
}
9-
.source_deps p {
10-
margin: 10px 0 5px;
11-
}
12-
.source_deps p:first-child {
13-
margin-top: 0;
14-
}
15-
.source_deps p:last-child {
16-
margin-bottom: 0;
17-
}
6+
.source_deps:empty {
7+
display: none;
8+
}
9+
10+
.source_deps p {
11+
margin: 10px 0 5px;
12+
}
13+
.source_deps p:first-child {
14+
margin-top: 0;
15+
}
16+
.source_deps p:last-child {
17+
margin-bottom: 0;
18+
}
19+
1820
body p.source_deps,
1921
.source_deps {
2022
margin: 20px 33.6% 20px 0;
2123
padding: 10px 25px;
2224
background: #f9f9f9;
2325
}
24-
.source_deps_used-by-specs,
25-
.source_deps_used-specs {
26-
margin-left: -5px !important;
27-
}
28-
.source_deps_used-by-specs > li,
29-
.source_deps_used-specs > li {
30-
list-style-type: none !important;
31-
}
32-
.source_deps_used-by-specs {
33-
display: none;
34-
}
35-
.source_deps_h_expand {
36-
border-bottom: 1px dashed;
37-
color: rgb(51,51,51);
38-
}
39-
.source_deps_h_expand:hover {
40-
text-decoration: none;
41-
color: rgb(100,100,100);
42-
}
26+
27+
.source_deps_used-by-specs,
28+
.source_deps_used-specs {
29+
margin-left: -5px !important;
30+
}
31+
32+
.source_deps_used-by-specs > li,
33+
.source_deps_used-specs > li {
34+
list-style-type: none !important;
35+
}
36+
37+
.source_deps_used-by-specs {
38+
display: none;
39+
}
40+
41+
.source_deps_h_expand {
42+
border-bottom: 1px dashed !important;
43+
color: rgb(51, 51, 51) !important;
44+
}
45+
.source_deps_h_expand:hover {
46+
text-decoration: none !important;
47+
color: rgb(100, 100, 100) !important;
48+
}

core/index.js

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
11
var fs = require('fs');
2+
var deepExtend = require('deep-extend');
23
var path = require('path');
34

4-
var includedDirs = global.opts.core.specDependenciesTree.includedDirs || [];
5-
var sourceRoot = global.opts.core.common.pathToUser;
6-
var infoFile = "info.json";
5+
var config = {
6+
includedDirs: [],
7+
outputFile: "data/spec_dependencies_tree.json",
8+
9+
// cron
10+
cron: false,
11+
cronProd: true,
12+
cronRepeatTime: 60000,
13+
14+
// file from parser get info
15+
infoFile: "info.json",
16+
sourceRoot: global.opts.core.common.pathToUser
17+
};
18+
// Overwriting base options
19+
deepExtend(config, global.opts.core.specDependenciesTree);
720

8-
// configuration for function timeout
9-
var CRON = global.opts.core.fileTree.cron;
10-
var CRON_PROD = global.opts.core.fileTree.cronProd;
11-
var CRON_REPEAT_TIME = global.opts.core.fileTree.cronRepeatTime;
1221

1322
var specDependenciesTree = function(dir) {
1423
var outputJSON = {},
1524
specsDirs = {};
1625

17-
includedDirs.forEach(function(includedDir) {
26+
config.includedDirs.forEach(function(includedDir) {
1827
specsDirs = fs.readdirSync(dir + '/' + includedDir);
1928

2029
specsDirs.forEach(function(specDir) {
2130
var pathToInfo = dir + '/' + includedDir + '/' + specDir;
2231

23-
if (fs.existsSync(pathToInfo + '/' + infoFile)) {
24-
var fileJSON = JSON.parse(fs.readFileSync(pathToInfo + '/' + infoFile, "utf8"));
32+
if (fs.existsSync(pathToInfo + '/' + config.infoFile)) {
33+
var fileJSON = JSON.parse(fs.readFileSync(pathToInfo + '/' + config.infoFile, "utf8"));
2534

2635
if (fileJSON['usedSpecs']) {
2736
fileJSON['usedSpecs'].forEach(function(usedSpec){
@@ -37,14 +46,14 @@ var specDependenciesTree = function(dir) {
3746
};
3847

3948
var SpecDependenciesWrite = function() {
40-
var outputFile = global.app.get('user') + "/" + global.opts.core.specDependenciesTree.outputFile;
49+
var outputFile = global.app.get('user') + "/" + config.outputFile;
4150
var outputPath = path.dirname(outputFile);
4251

4352
if (!fs.existsSync(outputPath)) {
4453
fs.mkdirSync(outputPath);
4554
}
4655

47-
fs.writeFile(outputFile, JSON.stringify(specDependenciesTree(sourceRoot), null, 4), function (err) {
56+
fs.writeFile(outputFile, JSON.stringify(specDependenciesTree(config.sourceRoot), null, 4), function (err) {
4857
if (err) {
4958
console.log('Error writing file tree of dependecies: ', err);
5059
} else {
@@ -55,9 +64,9 @@ var SpecDependenciesWrite = function() {
5564

5665
SpecDependenciesWrite();
5766

58-
// setcron
59-
if (CRON || (global.MODE === 'production' && CRON_PROD)) {
60-
setInterval(function(){
61-
SpecDependenciesWrite();
62-
}, CRON_REPEAT_TIME);
67+
// Running by cron
68+
if (config.cron || (global.MODE === 'production' && config.cronProd)) {
69+
setInterval(function () {
70+
writeDataFile();
71+
}, config.cronRepeatTime);
6372
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "sourcejs-spec-dependencies",
3-
"version": "0.1.5",
4-
"description": "Cross links of specs",
3+
"version": "0.1.6",
4+
"description": "Crosslinks of specs",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/sourcejs/sourcejs-spec-dependencies"

0 commit comments

Comments
 (0)