-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gulpfile.js
62 lines (54 loc) · 2.27 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
"use strict";
var os = require("os");
var gulp = require("gulp");
var gutil = require("gulp-util");
var jshint = require("gulp-jshint");
var uglify = require("gulp-uglifyjs");
var rename = require("gulp-rename");
var concat = require("gulp-concat");
var notify = require("gulp-notify");
var header = require("gulp-header");
var pkg = require("./package.json");
var dateFormat = require("dateformatter").format;
pkg.name = "Drv.js";
pkg.today = dateFormat;
var headerComment = ["/*",
" * <%= pkg.name %>",
" *",
" * @file <%= fileName(file) %> ",
" * @version <%= pkg.version %> ",
" * @description <%= pkg.description %>",
" * @license MIT License",
" * @author <%= pkg.author %>",
" * {@link <%= pkg.homepage %>}",
" * @updateTime <%= pkg.today('Y-m-d') %>",
" */",
"\r\n"].join("\r\n");
var headerMiniComment = "/*! <%= pkg.name %> v<%= pkg.version %> | <%= fileName(file) %> | <%= pkg.description %> | MIT License | By: <%= pkg.author %> | <%= pkg.homepage %> | <%=pkg.today('Y-m-d') %> */\r\n";
var srcFile = "./src/drv.js";
var distPath = "./dist";
gulp.task("js", function() {
return gulp.src(srcFile)
.pipe(jshint("./.jshintrc"))
.pipe(jshint.reporter("default"))
.pipe(header(headerComment, {pkg : pkg, fileName : function(file) {
var name = file.path.split(file.base);
return name[1].replace(/[\\\/]?/, "");
}}))
.pipe(gulp.dest(distPath))
.pipe(rename({ suffix: ".min" }))
.pipe(uglify()) //{outSourceMap: true}
.pipe(gulp.dest(distPath))
.pipe(header(headerMiniComment, {pkg : pkg, fileName : function(file) {
var name = file.path.split(file.base + ( (os.platform() === "win32") ? "\\" : "/") );
return name[1].replace(/[\\\/]?/, "");
}}))
.pipe(gulp.dest(distPath))
.pipe(notify({ message: "drv.js task complete" }));
});
gulp.task("watch", function() {
gulp.watch(srcFile, ["js"]);
});
gulp.task("default", function() {
gulp.run("js");
});