forked from oauthjs/angular-oauth2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
97 lines (85 loc) · 2.19 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
/**
* Module dependencies.
*/
var concat = require('gulp-concat');
var gulp = require('gulp');
var header = require('gulp-header');
var jshint = require('gulp-jshint');
var karma = require('karma').server;
var ngAnnotate = require('gulp-ng-annotate');
var pkg = require('./package.json');
var rename = require('gulp-rename');
var to5 = require('gulp-6to5');
var uglify = require('gulp-uglify');
var wrapUmd = require('gulp-wrap-umd');
/**
* Configuration
*/
var config = {
name: 'angular-oauth2.js',
entry: './src/angular-oauth2.js',
src: ['./src/*.js', './src/**/*.js'],
dest: './dist',
umd: {
namespace: 'angularOAuth2',
exports: 'ngModule',
deps: [
'angular',
{ name: 'query-string', globalName: 'queryString', paramName: 'queryString' }
]
},
banner: ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */',
''].join('\n')
};
/**
* Scripts task.
*/
gulp.task('scripts', ['scripts-lint'], function() {
return gulp.src(config.src)
.pipe(to5({ modules: 'ignore', blacklist: ['useStrict'] }))
.pipe(ngAnnotate({ single_quotes: true, add: true }))
.pipe(concat(config.name))
.pipe(wrapUmd(config.umd))
.pipe(uglify({
mangle: false,
output: { beautify: true },
compress: false
}))
.pipe(header(config.banner, { pkg: pkg }))
.pipe(gulp.dest(config.dest));
});
gulp.task('scripts-minify', ['scripts'], function() {
return gulp.src(config.dest + '/' + config.name)
.pipe(uglify())
.pipe(rename(function(path) {
path.extname = '.min.js';
}))
.pipe(gulp.dest(config.dest));
});
gulp.task('scripts-lint', function() {
return gulp.src(config.src)
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});
/**
* Test task.
*/
gulp.task('test', ['scripts'], function() {
return karma.start({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, function(code) {
console.log('Karma has exited with code', code);
});
});
/**
* Main tasks.
*/
gulp.task('build', ['scripts-minify']);
gulp.task('default', ['test']);