forked from mWater/minimongo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
50 lines (45 loc) · 1.55 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
var gulp = require("gulp");
var coffee = require('gulp-coffee');
var gutil = require('gulp-util');
var browserify = require('browserify');
var streamConvert = require('vinyl-source-stream');
var glob = require('glob');
var uglify = require('gulp-uglify');
var coffeeify = require('coffeeify');
var buffer = require('vinyl-buffer');
var rename = require("gulp-rename");
// Compilation
gulp.task('coffee', function() {
return gulp.src('./src/*.coffee')
.pipe(coffee({ bare: true }).on('error', gutil.log))
.pipe(gulp.dest('./lib/'));
});
gulp.task('copy', function() {
return gulp.src(['./src/**/*.js'])
.pipe(gulp.dest('./lib/'));
});
gulp.task('prepareTests', ['coffee', 'copy'], function() {
var bundler = browserify({entries: glob.sync("./test/*Tests.coffee"), extensions: [".coffee"] }).
transform(coffeeify);
var stream = bundler.bundle()
// TODO error handling not working
.on('error', gutil.log)
.on('error', function() { throw "Failed" })
.pipe(streamConvert('browserified.js'))
.pipe(gulp.dest('./test'));
return stream;
});
gulp.task('dist', ['copy', 'coffee'], function() {
bundler = browserify();
bundler.require("./jquery-shim.js", { expose: "jquery"});
bundler.require("./lodash-shim.js", { expose: "lodash"});
bundler.require("./index.js", { expose: "minimongo"});
return bundler.bundle()
.pipe(streamConvert('minimongo.js'))
.pipe(gulp.dest("./dist/"))
.pipe(buffer())
.pipe(rename("minimongo.min.js"))
.pipe(uglify())
.pipe(gulp.dest('./dist/'));
});
gulp.task('default', ['coffee', 'copy', 'dist']);