forked from pagekit/pagekit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
68 lines (59 loc) · 1.89 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
/**
* Popular Tasks
* -------------
*
* compile: compiles the .less files of the specified packages
* lint: runs jshint on all .js files
*/
var merge = require('merge-stream'),
gulp = require('gulp'),
header = require('gulp-header'),
less = require('gulp-less'),
rename = require('gulp-rename'),
eslint = require('gulp-eslint');
// paths of the packages for the compile-task
var pkgs = [
{ path: 'app/installer/', data: '../../composer.json' },
{ path: 'app/system/modules/theme/', data: '../../../../composer.json' },
{ path: 'themes/alpha/', data: 'theme.json' }
];
// banner for the css files
var banner = "/*! <%= data.title %> <%= data.version %> | (c) 2014 Pagekit | MIT License */\n";
gulp.task('default', ['compile']);
/**
* Compile all less files
*/
gulp.task('compile', function () {
return merge.apply(null, pkgs.map(function (pkg) {
return gulp.src(pkg.path + '**/less/*.less', {base: pkg.path})
.pipe(less({ compress: true, relativeUrls: true }))
.pipe(header(banner, { data: require('./' + pkg.path + pkg.data) }))
.pipe(rename(function (file) {
// the compiled less file should be stored in the css/ folder instead of the less/ folder
file.dirname = file.dirname.replace('less', 'css');
}))
.pipe(gulp.dest(pkg.path));
}));
});
/**
* Watch for changes in files
*/
gulp.task('watch', function () {
gulp.watch('**/*.less', ['compile']);
});
/**
* Lint all script files
*/
gulp.task('lint', function () {
return gulp.src([
'app/modules/**/*.js',
'app/system/**/*.js',
'extensions/**/*.js',
'themes/**/*.js',
'!**/bundle/*',
'!**/vendor/**/*'
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError());
});