forked from goinstant/goangular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
99 lines (83 loc) · 2.37 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
/* jshint node:true */
'use strict';
var harp = require('harp');
var gulp = require('gulp');
var gulpConventionalChangelog = require('gulp-conventional-changelog');
var gulpLoadPlugins = require('gulp-load-plugins');
var plugins = gulpLoadPlugins();
var pathTo = {
clean: ['build/', 'dist/'],
watch: ['lib/**.js', 'index.js'],
watchBuild: 'build/build.js',
tests: ['tests/*.js'],
entry: 'index.js',
build: 'build/',
dist: 'dist/'
};
gulp.task('clean', function() {
gulp.src(pathTo.clean, { read: false }).pipe(plugins.clean({ force: true }));
});
gulp.task('lint', function() {
gulp.src(pathTo.watch)
.pipe(plugins.jshint('.jshintrc'))
.pipe(plugins.jshint.reporter('jshint-stylish'))
.pipe(gulp.dest(pathTo.build));
});
gulp.task('develop', ['clean'], function() {
console.log('ding')
gulp.src(pathTo.entry)
.pipe(plugins.browserify())
.pipe(plugins.rename('build.js'))
.pipe(gulp.dest(pathTo.build));
});
gulp.task('build', ['clean', 'develop'], function() {
gulp.src(pathTo.entry)
.pipe(plugins.browserify())
.pipe(plugins.rename('goangular.js'))
.pipe(gulp.dest(pathTo.dist))
.pipe(plugins.uglify())
.pipe(plugins.rename('goangular.min.js'))
.pipe(gulp.dest(pathTo.dist));
});
gulp.task('test', function() {
return gulp.src(pathTo.tests)
.pipe(plugins.karma({
configFile: 'karma.conf.js',
browsers: ['PhantomJS'],
action: 'run'
}))
.on('error', throwErr);
});
gulp.task('tdd', function() {
return gulp.src(pathTo.tests)
.pipe(plugins.karma({
configFile: 'karma.conf.js',
action: 'start'
}))
.on('error', throwErr);
});
gulp.task('default', ['clean', 'develop'], function() {
harp.server(__dirname, { port: 5000 });
var options = {
url: 'http://localhost:5000/examples/',
app: 'Google Chrome'
};
gulp.src('./examples/index.html')
.pipe(plugins.open('', options))
.pipe(gulp.dest(pathTo.dist));
gulp.watch(pathTo.watch).on('change', function() {
gulp.start('develop');
});
var livereload = plugins.livereload();
gulp.watch(pathTo.watchBuild).on('change', function(file) {
livereload.changed(file.path);
});
});
gulp.task('changelog', function(){
return gulp.src(['package.json', 'CHANGELOG.md'])
.pipe(gulpConventionalChangelog())
.pipe(gulp.dest('.')); // will output one file only
});
function throwErr(err) {
throw err;
}