-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
29 lines (27 loc) · 855 Bytes
/
index.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
/**
* Homemade gulp options manager
*/
module.exports = {
options: null,
read: function(argv) {
var optionsClean = {};
argv.slice(2, argv.length).forEach(function(p) {
if (p.indexOf('--') === 0 && p.length !== 2) {
var splitParam = p.replace('--', '').split('=');
var param = splitParam[0];
var value = (splitParam[1] !== undefined) ? splitParam[1] : '';
optionsClean[param] = value;
}
});
return optionsClean;
},
has: function(param) {
if (!this.options) {
this.options = this.read(process.argv);
}
return (Object.prototype.hasOwnProperty.call(this.options, param));
},
get: function(param) {
return (this.has(param)) ? this.options[param] : undefined;
}
};