Repository navigation
Expand file tree
/
Copy pathgulpfile-paths.js
More file actions
144 lines (126 loc) · 2.33 KB
/
Copy pathgulpfile-paths.js
File metadata and controls
144 lines (126 loc) · 2.33 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
var Paths = function(){
/**
* Source files' directory
* @type {string}
* @private
*/
this._src = "./src";
/**
* Destination files' directory
* @type {string}
* @private
*/
this._dest = "./dest";
/**
* Files' paths
* @type {Object}
*/
this.paths = {
// all HTML pages
"html": {
"pages": {
"src": "/*.html",
"dest": "/"
},
"yuidocs": {
"src": "/yui-docs/**",
"dest": "/yui-docs/"
}
},
// all LESS files to convert into CSS
"less": {
"src": "/less/style.less",
"dest": "/css/",
"destFile": "style.css"
},
// all scripts
"js": {
"src": "/js/**/*.*",
"dest": "/js/"
},
// all images
"images": {
"src": "/images/**/*.*",
"dest": "/images/"
},
// all fonts
"fonts": {
"src": "/fonts/**/*.*",
"dest": "/fonts/"
},
// vendor files
"vendor": {
"src": "/vendor/**/*.*",
"dest": "/vendor/"
},
// zip files
"files": {
"src": "/files/**/*.*",
"dest": "/files/"
}
};
/**
* Get source files' path by property's path
* @param propPath
*/
this.src = function(propPath){
if(propPath === undefined){
return this._src;
}
else{
var fullLocalPath = propPath + ".src";
var filePath = this.get(fullLocalPath);
return (filePath === undefined) ?
undefined : this._src + filePath;
}
};
/**
* Get destination files' path by property's path
* @param propPath
*/
this.dest = function(propPath){
if(propPath === undefined){
return this._dest;
}
else{
var fullLocalPath = propPath + ".dest";
var filePath = this.get(fullLocalPath);
return (filePath === undefined) ?
undefined : this._dest + filePath;
}
};
/**
* Set new "_src" value
* @param newSrc {String} New value
*/
this.setSrc = function(newSrc){
this._src = newSrc;
};
/**
* Set new "_dest" value
* @param newDest {String} New value
*/
this.setDest = function(newDest){
this._dest = newDest;
};
/**
* Find a property in an object by path
* @param path {String} e.g. "foo.bar.baz"
* @private
*/
this.get = function(path){
var paths = path.split('.'),
current = this.paths,
i;
for (i = 0; i < paths.length; i++) {
if (current[paths[i]] == undefined) {
return undefined;
} else {
current = current[paths[i]];
}
}
return current;
};
};
var paths = new Paths();
module.exports = paths;