forked from ionic-team/ng-cordova
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
118 lines (103 loc) · 3.27 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
var gulp = require('gulp'),
buildConfig = require('./config/build.config'),
concat = require('gulp-concat'),
argv = require('minimist')(process.argv.slice(2)),
footer = require('gulp-footer'),
header = require('gulp-header'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
karma = require('karma').server,
karmaConf = require('./config/karma.conf.js'),
rename = require('gulp-rename'),
shell = require('gulp-shell'),
prettify = require('gulp-prettify'),
changelog = require('conventional-changelog'),
q = require('q'),
fs = require('fs'),
jscs = require('gulp-jscs'),
git = require('gulp-git');
gulp.task('default', ['git', 'build']);
gulp.task('lint', ['jshint', 'jscs']);
gulp.task('build', function () {
gulp.src(buildConfig.mockFiles)
.pipe(concat('ng-cordova-mocks.js'))
.pipe(header(buildConfig.closureStart))
.pipe(footer(buildConfig.closureEnd))
.pipe(header(buildConfig.banner))
.pipe(gulp.dest(buildConfig.dist))
.pipe(uglify())
.pipe(header(buildConfig.banner))
.pipe(rename({
extname: '.min.js'
}))
.pipe(gulp.dest(buildConfig.dist));
return gulp.src(buildConfig.pluginFiles)
.pipe(concat('ng-cordova.js'))
.pipe(header(buildConfig.closureStart))
.pipe(footer(buildConfig.closureEnd))
.pipe(header(buildConfig.banner))
.pipe(gulp.dest(buildConfig.dist))
.pipe(gulp.dest(buildConfig.demo.ngCordova))
.pipe(uglify())
.pipe(header(buildConfig.banner))
.pipe(rename({extname: '.min.js'}))
.pipe(gulp.dest(buildConfig.dist))
.pipe(gulp.dest(buildConfig.demo.ngCordova));
});
gulp.task('changelog', function () {
var version = buildConfig.versionData.version;
var dest = 'CHANGELOG.md';
return makeChangelog(version).then(function (log) {
fs.writeFileSync(dest, log);
});
});
function makeChangelog(version) {
var file = __dirname + '/CHANGELOG.md';
var deferred = q.defer();
changelog({
repository: 'https://github.com/driftyco/ng-cordova',
version: version,
file: file
}, function (err, log) {
if (err) deferred.reject(err);
else deferred.resolve(log);
});
return deferred.promise;
}
gulp.task('karma', function (done) {
karmaConf.singleRun = true;
argv.browsers && (karmaConf.browsers = argv.browsers.trim().split(','));
argv.reporters && (karmaConf.reporters = argv.reporters.trim().split(','));
karma.start(karmaConf, done);
});
gulp.task('jshint', function () {
return gulp.src('./src/plugins/*.js')
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});
gulp.task('jscs', function () {
gulp.src('src/plugins/*.js')
.pipe(jscs({
fix: true,
"requireSpaceAfterKeywords": ['function']
}))
.pipe(gulp.dest('src/plugins/'));
gulp.src('./src/mocks/*.js')
.pipe(jscs({
fix: true,
"requireSpaceAfterKeywords": ['function']
}))
.pipe(gulp.dest('src/mocks/'));
});
gulp.task('karma-watch', function (done) {
console.log(karmaConf);
karmaConf.singleRun = false;
karma.start(karmaConf, done);
});
gulp.task('watch', ['build'], function () {
gulp.watch(['src/**/*.js', 'test/**/*.js'], ['build']);
});
gulp.task('run-demo', ['watch'], shell.task([
'cd demo && ionic run ios -l -c --target="iPhone (Retina 4-inch)"'
]));