This repository has been archived by the owner on Aug 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
80 lines (70 loc) · 2.17 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
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
////////////////////
// build
////////////////////
gulp.task('build', ['compile-stylus', 'jshint']);
////////////////////
// default
////////////////////
gulp.task('default', $.taskListing.withFilters(null, 'default'));
////////////////////
// compile-stylus
////////////////////
gulp.task('compile-stylus', function() {
return gulp.src([__dirname + '/www/lib/onsen/stylus/*-theme.styl'])
.pipe(plumber())
.pipe($.stylus({errors: true, define: {mylighten: mylighten}}))
.pipe($.autoprefixer('> 1%', 'last 2 version', 'ff 12', 'ie 8', 'opera 12', 'chrome 12', 'safari 12', 'android 2'))
.pipe($.rename(function(path) {
path.dirname = '.';
path.basename = 'onsen-css-components-' + path.basename;
path.ext = 'css';
}))
.pipe(gulp.dest(__dirname + '/www/styles/'));
// needs for compile
function mylighten(param) {
if (param.rgba) {
var result = param.clone();
result.rgba.a = 0.2;
return result;
}
throw new Error('mylighten() first argument must be color.');
}
});
////////////////////
// jshint
////////////////////
gulp.task('jshint', function() {
return gulp.src([__dirname + '/www/*.js', __dirname + '/www/js/**/*.js'])
.pipe(plumber())
.pipe($.cached('jshint'))
.pipe($.jshint())
.pipe(jshintNotify())
.pipe($.jshint.reporter('jshint-stylish'));
});
////////////////////
// prepare-cordova
////////////////////
gulp.task('prepare-cordova', function() {
return gulp.src('')
.pipe($.plumber())
.pipe($.shell(['cordova prepare'], {cwd: __dirname}));
});
// utils
function plumber() {
return $.plumber({errorHandler: $.notify.onError()});
}
function jshintNotify() {
return $.notify(function(file) {
if (file.jshint.success) {
return false;
}
var errors = file.jshint.results.map(function (data) {
return data.error ? '(' + data.error.line + ':' + data.error.character + ') ' + data.error.reason : '';
}).join('\n');
return file.relative + ' (' + file.jshint.results.length + ' errors)\n' + errors;
});
}