forked from luiscarlosjayk/angular-facebook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
101 lines (81 loc) · 2 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
/* global process, require */
var gulp = require('gulp');
var gutil = require('gulp-util');
var connect = require('gulp-connect');
var rename = require("gulp-rename");
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var uglify = require('gulp-uglify');
var Server = require('karma').Server;
var path = require('path');
var karma = require('karma');
var karmaParseConfig = require('karma/lib/config').parseConfig;
function runKarma(configFilePath, options, cb) {
configFilePath = path.resolve(configFilePath);
var log = gutil.log;
var colors = gutil.colors;
var config = karmaParseConfig(configFilePath, {});
Object.keys(options).forEach(function(key) {
config[key] = options[key];
});
new Server(config, function(exitCode) {
log('Karma has exited with ' + colors.red(exitCode));
cb();
process.exit(exitCode);
}).start();
}
gulp.task('lint', function() {
return gulp.src([
'./lib/**/*.js',
'./test/**/*.js'
])
.pipe(jshint())
.pipe(jshint.reporter(stylish));
});
gulp.task('watch', function () {
gulp.watch([
'./lib/**/*.js',
'./test/**/*.js',
'./gulpfile.js'
], ['lint']);
gulp.start('test-dev');
});
gulp.task('test', function(cb) {
runKarma('karma.conf.js', {
autoWatch: false,
singleRun: true,
browsers: ['PhantomJS']
}, cb);
});
gulp.task('test-dev', function(cb) {
runKarma('karma.conf.js', {
autoWatch: true,
singleRun: false
}, cb);
});
gulp.task('prepare-testapp', function () {
gulp.src([
'./bower_components/**',
'./lib/**',
], {
base: '.'
}).pipe(gulp.dest('./testapp'));
connect.server({
root: 'testapp',
port: 3333
});
});
gulp.task('distribute', function() {
gulp
.src('./lib/*.js')
.pipe(gulp.dest('./dist'));
gulp
.src('lib/angular-facebook.js')
.pipe(uglify())
.pipe(rename('angular-facebook.min.js'))
.pipe(gulp.dest('dist'));
});
gulp.task('default', function() {
gulp.start('lint');
gulp.start('distribute');
});