forked from pombredanne/taiga-layout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulp-utils.js
74 lines (58 loc) · 1.73 KB
/
gulp-utils.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
var exports = module.exports = {};
var fs = require("fs");
var Theme = function() {
var defaultTheme = "taiga";
var themesPath = "app/themes";
var tmpThemesPath = "tmp/themes";
var themesSequenceIndex = 0;
var themesSequence = [];
var searchIndex = function(name) {
for(var i = 0; i < themesSequence.length; i++) {
if (themesSequence[i].name === name) {
return i;
}
}
};
var initThemes = function () {
var availableThemes = {};
var files = fs.readdirSync(themesPath);
files.forEach(function(file) {
var path = themesPath + '/' + file;
var tmpPath = tmpThemesPath + '/' + file;
if (fs.statSync(path).isDirectory()) {
availableThemes[file] = {
name: file,
path: path,
customVariables: path + "/variables.scss",
customScss: path + "/custom.scss",
customCss: tmpPath + "/custom.css",
};
}
});
themesSequence.push(availableThemes[defaultTheme]);
for (var theme in availableThemes) {
if (theme !== defaultTheme) {
themesSequence.push(availableThemes[theme]);
}
}
};
initThemes();
var obj = {};
obj.next = function() {
themesSequenceIndex++;
};
obj.set = function(name) {
themesSequenceIndex = searchIndex(name);
};
Object.defineProperty(obj, "current", {
get: function() {
return themesSequence[themesSequenceIndex];
}
});
return obj;
};
exports.themes = {
sequence: function() {
return Theme();
}
};