-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
64 lines (57 loc) · 1.43 KB
/
gulpfile.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
"use strict";
var gulp = require('gulp'),
less = require('gulp-less'),
path = require('path'),
argv = require('yargs').argv,
watch = require('gulp-watch'),
colors = require('colors/safe'),
Basic, s;
Basic = {
settings: {
fileName: './less/style.less',
sourceDir: '**/*.less',
destination: './css'
},
init: function() {
s = this.settings;
},
extend: function(default_opt,custom_opt) {
// Similar to jQuery extend
var i, opt = {};
for(i in default_opt) {
if(i) {
opt[i] = (custom_opt[i])?custom_opt[i]:default_opt[i];
}
}
return opt;
},
dateTime: function() {
var date,hours,minutes,ampm,strTime;
date = new Date();
hours = date.getHours();
minutes = date.getMinutes();
ampm = hours >= 12 ? 'pm' : 'am';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
minutes = minutes < 10 ? '0'+minutes : minutes;
strTime = hours + ':' + minutes + ' ' + ampm;
return date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear() + " " + strTime;
},
compile: function(opt) {
// fileName can have with directory structure
gulp.src(opt.fileName)
.pipe(less())
.pipe(gulp.dest(opt.destination));
console.log(this.dateTime());
}
};
// Initiate the settings
Basic.init();
gulp.task('watch', function() {
var opt = Basic.extend(Basic.settings,argv);
watch(opt.sourceDir, function() {
Basic.compile(opt);
});
})
// Assign tasks
.task('default', ['watch']);