-
Notifications
You must be signed in to change notification settings - Fork 11
/
gulpfile.js
102 lines (91 loc) · 3.15 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
var gulp = require('gulp');
var gutil = require('gulp-util');
var bower = require('bower');
var sass = require('gulp-sass');
var cleanCss = require('gulp-clean-css');
var rename = require('gulp-rename');
var sh = require('shelljs');
var del = require('del');
var jshint = require('gulp-jshint');
var requiredCordovaPlugins = [
'https://github.com/VersoSolutions/CordovaClipboard', // only master available
'https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git#2.5.2',
'https://github.com/wymsee/cordova-HTTP.git#v1.2.0',
'https://github.com/robertklein/cordova-ios-security.git', // only master branch available
'https://github.com/gitawego/cordova-screenshot.git#v0.1.5'
];
gulp.task('sass', function() {
return processSass();
});
gulp.task('sass:watch', function() {
gulp.watch('./scss/ionic.app.scss', ['sass']);
});
gulp.task('lint', function() {
return gulp.src('./www/js/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});
gulp.task('bower', function(done) {
bower.commands.install()
.on('log', function(data) {
gutil.log('bower', gutil.colors.cyan(data.id), data.message);
}).on('end', function() {
done();
}).on('error', function() {
printErrorMessageAndExit('ERROR: Bower install ended NOT OK!');
});
});
gulp.task('cordova', function(done) {
for (var i = 0; i < requiredCordovaPlugins.length; i++) {
var plugin = requiredCordovaPlugins[i];
if (sh.exec('ionic plugin add --nosave ' + plugin).code !== 0) {
printErrorMessageAndExit('Error: Couldn\'t install Cordova plugin ' + plugin);
}
}
done();
});
gulp.task('git:check', function(done) {
if (!sh.which('git')) {
printErrorMessageAndExit('Git is not installed.\n' +
'Git, the version control system, is required to download Ionic.\n' +
'Download git here: http://git-scm.com/downloads\n' +
'Once git is installed, run \'gulp install\' again.'
);
}
done();
});
gulp.task('install', ['git:check', 'cordova', 'bower'], function() {
// this is a hack for simulating a synchronous behavior
console.log("*** Compiling SASS ***");
processSass();
});
gulp.task('clean', function(done) {
del([
'node_modules/**',
'plugins/**',
'platforms/**',
'www/css/**',
'www/lib/**'
], done());
});
function printErrorMessageAndExit(msg) {
console.log(gutil.colors.red(msg));
process.exit(1);
}
function processSass() {
return gulp.src('./scss/ionic.app.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./www/css/'))
.pipe(cleanCss({ keepSpecialComments: 0 }))
.pipe(rename({ extname: '.min.css' }))
.pipe(gulp.dest('./www/css/'));
}