forked from nebulasio/nebPay.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
116 lines (99 loc) · 3.14 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
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
#!/usr/bin/env node
'use strict';
var version = require('./libs/version.json');
var path = require('path');
var del = require('del');
var gulp = require('gulp');
var browserify = require('browserify');
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var plumber = require('gulp-plumber');
var notify = require('gulp-notify');
var source = require('vinyl-source-stream');
var exorcist = require('exorcist');
var streamify = require('gulp-streamify');
var replace = require('gulp-replace');
var babelify = require('babelify');
var buffer = require('vinyl-buffer');
var jsdoc = require("gulp-jsdoc3");
var pkg = require("./package.json");
var DEST = path.join(__dirname, 'dist/');
var dst = 'nebPay';
var documentationDst = path.join(__dirname, 'docs/');
// Error / Success Handling
var onError = function(err) {
notify.onError({
title: "Error: " + err.plugin,
subtitle: "<%= file.relative %>",
message: "<%= error.message %>",
sound: "Beep",
})(err);
console.log(err.toString())
this.emit('end');
}
function onSuccess(msg) {
return {
message: msg + " Complete! ",
onLast: true
}
}
function notifyFunc(msg) {
return gulp.src('.', { read: false })
.pipe(notify(onSuccess(msg)))
}
var browserifyOptions = {
debug: true,
insert_global_vars: false, // jshint ignore:line
detectGlobals: false,
bundleExternal: true
};
gulp.task('version', function(){
gulp.src(['./package.json'])
.pipe(replace(/\"version\"\: \"([\.0-9]*)\"/, '"version": "'+ version.version + '"'))
.pipe(gulp.dest('./'));
});
gulp.task('lint', [], function(){
return gulp.src(['./nebpay.js', './libs/*.js'])
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('clean', ['lint'], function(cb) {
del([ DEST ]).then(cb.bind(null, null));
});
gulp.task('nebpay', ['clean'], function () {
return browserify()
.require('./nebpay.js', {expose: 'nebpay'})
.transform(babelify)
.bundle()
.pipe(plumber({ errorHandler: onError }))
// .pipe(exorcist(path.join( DEST, nebulasDst + '.js.map')))
.pipe(source('nebPay.js'))
.pipe(buffer())
.pipe(rename(dst + '.js'))
.pipe(gulp.dest(DEST))
.pipe(uglify())
.pipe(rename(dst + '.min.js'))
.pipe(gulp.dest(DEST));
});
gulp.task('watch', function() {
gulp.watch(['./libs/*.js'], ['lint', 'build']);
});
gulp.task('documentation', function(cb) {
gulp.src(['README.md', './libs/*.js'])
.pipe(jsdoc({
opts: {
destination: documentationDst,
"template": "./docs-data/template"
},
templates: {
"systemName" : pkg.description,
"logoFile" : "img/logo.png",
"copyright" : pkg.copyright,
"theme" : "lumen",
"linenums" : true,
"sort" : false,
}
}, cb))
});
gulp.task('default', ['version', 'lint', 'clean', 'nebpay']);