-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.js
53 lines (46 loc) · 1.5 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
var gulp = require("gulp"),
gulpUglify = require("gulp-uglify"),
gulpRename = require("gulp-rename"),
gulpHeader = require("gulp-header"),
gulpJsBeautifier = require("gulp-jsbeautifier"),
del = require("del"),
pkg = require("./package.json");
var header = [
"/*!",
"* <%= pkg.name %> v<%= pkg.version %>",
"* A lightweight Promises/A+ compliant implementation of ECMAScript Promise API.",
"* Here the Belofte is an Afrikaans word, It means Promise.",
"* This library is very useful for old browsers or old Javascript engines where",
"* native Promise API is not available.",
"*",
"* @license Copyright (c) 2017-2018 Rousan Ali, <%= pkg.license %> License",
"*",
"* Codebase: <%= pkg.url %>",
"* Homepage: <%= pkg.homepage %>",
"* Date: <%= pkg.buildDate %>",
"*/",
""
].join("\n");
var parts = [
"src/belofte.js"
];
pkg["buildDate"] = new Date();
pkg["name"] = pkg.name.replace(/^b/, function (found) {
return found.toUpperCase();
});
gulp.task("clean", function () {
return del(["./dist/*"]);
});
gulp.task("header", ["clean"], function() {
return gulp.src(parts)
.pipe(gulpHeader(header, { pkg: pkg }))
.pipe(gulpJsBeautifier())
.pipe(gulp.dest("./dist"));
});
gulp.task("uglify", ["header"], function () {
return gulp.src("./dist/belofte.js")
.pipe(gulpUglify())
.pipe(gulpRename({suffix:".min"}))
.pipe(gulp.dest("./dist"));
});
gulp.task("default", ["clean", "header", "uglify"]);