-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathgulpfile.js
81 lines (70 loc) · 2.5 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
var karma = require('karma').server,
gulp = require('gulp'),
jshint = require('gulp-jshint'),
header = require('gulp-header'),
rename = require('gulp-rename'),
ngAnnotate = require('gulp-ng-annotate'),
uglify = require('gulp-uglify'),
browserify = require('gulp-browserify'),
fs = require('fs'),
del = require('del'),
jsonfile = require('jsonfile'),
GitDown = require('gitdown');
gulp.task('lint', function () {
return gulp
.src('./src/*.js')
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('clean', ['lint'], function (cb) {
del(['dist']).then(function () {
cb();
});
});
gulp.task('bundle', ['clean'], function () {
return gulp
.src('./src/angular-swing.js')
.pipe(ngAnnotate({
add: true
}))
.pipe(browserify({
//debug : true
}))
.pipe(gulp.dest('./dist/'));
});
gulp.task('version', ['bundle'], function () {
var name = 'angular-swing',
pkg = jsonfile.readFileSync('./package.json'),
bower = jsonfile.readFileSync('./bower.json');
gulp
.src('./dist/' + name + '.js')
.pipe(header('/**\n * @version <%= version %>\n * @link https://github.com/gajus/' + name + ' for the canonical source repository\n * @license https://github.com/gajus/' + name + '/blob/master/LICENSE BSD 3-Clause\n */\n', {version: pkg.version}))
.pipe(gulp.dest('./dist/'))
.pipe(uglify())
.pipe(rename(name + '.min.js'))
.pipe(header('/**\n * @version <%= version %>\n * @link https://github.com/gajus/' + name + ' for the canonical source repository\n * @license https://github.com/gajus/' + name + '/blob/master/LICENSE BSD 3-Clause\n */\n', {version: pkg.version}))
.pipe(gulp.dest('./dist/'));
bower.name = pkg.name;
bower.description = pkg.description;
bower.version = pkg.version;
bower.keywords = pkg.keywords;
bower.license = pkg.license;
bower.authors = [pkg.author];
jsonfile.writeFileSync('./bower.json', bower);
});
gulp.task('gitdown', function () {
return GitDown
.read('.gitdown/README.md')
.write('README.md');
});
gulp.task('watch', function () {
gulp.watch(['./src/*', './package.json'], ['default']);
gulp.watch(['./.gitdown/*'], ['gitdown']);
});
gulp.task('test', ['default'], function (cb) {
karma.start({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, cb);
});
gulp.task('default', ['version']);