-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
77 lines (65 loc) · 2.22 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
/** gulpfile
*
* author: jbroglio
* Date: 5/13/14
* Time: 10:43 AM
*/
var gulp = require('gulp'),
del = require('del'),
mocha = require('gulp-mocha'),
rename = require('gulp-rename'),
plumber = require('gulp-plumber'),
notify = require('gulp-notify'),
fs = require('fs')
;
gulp.task('default', ['clean'], function () {
gulp.start('test', 'js', 'examples', 'package', 'top', 'testFiles');
});
gulp.task('testFiles', function () {
return gulp.src('test/**')
.pipe(gulp.dest('dist/test'))
});
gulp.task('js', function () {
return gulp.src('lib/*.js')
.pipe(gulp.dest('dist/lib/'));
});
gulp.task('examples', function () {
return gulp.src((['examples/*.js', 'examples/*.json']))
.pipe(gulp.dest('dist/examples'));
});
gulp.task('package',
function () {
// remove gulp packages from npm version of package.json
// (I could not find a gulp plugin for doing this).
var npmpkg = 'npm-package.json';
return fs.readFile('package.json', function (err, txt) {
if (err) throw err;
txt = ''+txt;
var json = JSON.parse(txt);
Object.keys(json.devDependencies).forEach(function(k){
if (/gulp/.test(k)) delete json.devDependencies[k];
});
txt = JSON.stringify(json, null, 4);
return fs.writeFile(npmpkg, txt, function (err) {
if (err) throw err;
return gulp.src((npmpkg))
.pipe(rename('package.json'))
.pipe(gulp.dest('dist'));
})
});
});
gulp.task('top', function(){
return gulp.src(['LICENSE','CHANGES.md', 'index.js','README.md'])
.pipe(gulp.dest('dist'));
});
gulp.task('clean', function (cb) {
del(['dist/*'], cb);
});
gulp.task('test', function () {
return gulp.src('test/*Spec.js', {read: false})
.pipe(plumber({errorHandler: //function(error) {
//var errs = JSON.stringify(error);
//notify.onError("Error:"+errs+"\n "+ "<%= error.stack ? error.stack : '' %>")();}}))
notify.onError("Error: <%= error %>, <%= error.stack ? error.stack : '' %>")}))
.pipe(mocha({useColors: false, reporter: 'spec'}));
});