scratch – Blame information for rev 58

Subversion Repositories:
Rev:
Rev Author Line No. Line
58 office 1 // jshint node:true
2 'use strict';
3  
4 var gulp = require('gulp'),
5 del = require('del'),
6 vinylPaths = require('vinyl-paths'),
7 $ = require('gulp-load-plugins')();
8  
9 var paths = {
10 scripts: ['src/trumbowyg.js'],
11 langs: ['src/langs/**.js', '!src/langs/en.js'],
12 plugins: ['plugins/*/**.js', '!plugins/*/gulpfile.js'],
13 icons: ['src/ui/icons/**.svg', 'plugins/*/ui/icons/**.svg'],
14 mainStyle: 'src/ui/sass/trumbowyg.scss',
15 styles: {
16 sass: 'src/ui/sass'
17 }
18 };
19  
20 var pkg = require('./package.json');
21 var banner = ['/**',
22 ' * <%= pkg.title %> v<%= pkg.version %> - <%= pkg.description %>',
23 ' * <%= description %>',
24 ' * ------------------------',
25 ' * @link <%= pkg.homepage %>',
26 ' * @license <%= pkg.license %>',
27 ' * @author <%= pkg.author.name %>',
28 ' * Twitter : @AlexandreDemode',
29 ' * Website : <%= pkg.author.url.replace("http://", "") %>',
30 ' */',
31 '\n'].join('\n');
32 var bannerLight = ['/** <%= pkg.title %> v<%= pkg.version %> - <%= pkg.description %>',
33 ' - <%= pkg.homepage.replace("http://", "") %>',
34 ' - License <%= pkg.license %>',
35 ' - Author : <%= pkg.author.name %>',
36 ' / <%= pkg.author.url.replace("http://", "") %>',
37 ' */',
38 '\n'].join('');
39  
40  
41 gulp.task('clean', function () {
42 return gulp.src('dist/*')
43 .pipe(vinylPaths(del));
44 });
45  
46 gulp.task('test', ['test-scripts', 'test-langs', 'test-plugins']);
47 gulp.task('test-scripts', function () {
48 return gulp.src(paths.scripts)
49 .pipe($.jshint())
50 .pipe($.jshint.reporter('jshint-stylish'));
51 });
52 gulp.task('test-langs', function () {
53 return gulp.src(paths.langs)
54 .pipe($.jshint())
55 .pipe($.jshint.reporter('jshint-stylish'));
56 });
57 gulp.task('test-plugins', function () {
58 return gulp.src(paths.plugins)
59 .pipe($.jshint())
60 .pipe($.jshint.reporter('jshint-stylish'));
61 });
62  
63 gulp.task('scripts', ['test-scripts'], function () {
64 return gulp.src(paths.scripts)
65 .pipe($.header(banner, {pkg: pkg, description: 'Trumbowyg core file'}))
66 .pipe($.newer('dist/trumbowyg.js'))
67 .pipe($.concat('trumbowyg.js', {newLine: '\r\n\r\n'}))
68 .pipe(gulp.dest('dist/'))
69 .pipe($.size({title: 'trumbowyg.js'}))
70 .pipe($.rename({suffix: '.min'}))
71 .pipe($.uglify())
72 .pipe($.header(bannerLight, {pkg: pkg}))
73 .pipe(gulp.dest('dist/'))
74 .pipe($.size({title: 'trumbowyg.min.js'}));
75 });
76  
77 gulp.task('langs', ['test-langs'], function () {
78 return gulp.src(paths.langs)
79 .pipe($.rename({suffix: '.min'}))
80 .pipe($.uglify({
81 preserveComments: 'all'
82 }))
83 .pipe(gulp.dest('dist/langs/'));
84 });
85  
86 gulp.task('plugins', ['test-plugins'], function () {
87 return gulp.src(paths.plugins)
88 .pipe(gulp.dest('dist/plugins/'))
89 .pipe($.rename({suffix: '.min'}))
90 .pipe($.uglify())
91 .pipe(gulp.dest('dist/plugins/'));
92 });
93  
94  
95  
96 gulp.task('icons', function () {
97 return gulp.src(paths.icons)
98 .pipe($.rename({prefix: 'trumbowyg-'}))
99 .pipe($.svgmin())
100 .pipe($.svgstore({ inlineSvg: true }))
101 .pipe(gulp.dest('dist/ui/'));
102 });
103  
104  
105  
106 gulp.task('styles', function () {
107 return gulp.src(paths.mainStyle)
108 .pipe($.sass({
109 sass: paths.styles.sass
110 }))
111 .pipe($.autoprefixer(['last 1 version', '> 1%', 'ff >= 20', 'ie >= 9', 'opera >= 12', 'Android >= 2.2'], {cascade: true}))
112 .pipe($.header(banner, {pkg: pkg, description: 'Default stylesheet for Trumbowyg editor'}))
113 .pipe(gulp.dest('dist/ui/'))
114 .pipe($.size({title: 'trumbowyg.css'}))
115 .pipe($.rename({suffix: '.min'}))
116 .pipe($.minifyCss())
117 .pipe($.header(bannerLight, {pkg: pkg}))
118 .pipe(gulp.dest('dist/ui/'))
119 .pipe($.size({title: 'trumbowyg.min.css'}));
120 });
121  
122  
123 gulp.task('sass-dist', ['styles'], function () {
124 return gulp.src('src/ui/sass/**/*.scss')
125 .pipe($.header(banner, {pkg: pkg, description: 'Default stylesheet for Trumbowyg editor'}))
126 .pipe(gulp.dest('dist/ui/sass'));
127 });
128  
129  
130 gulp.task('watch', function () {
131 gulp.watch(paths.icons, ['icons']);
132 gulp.watch(paths.scripts, ['scripts']);
133 gulp.watch(paths.langs, ['langs']);
134 gulp.watch(paths.plugins, ['plugins']);
135 gulp.watch(paths.mainStyle, ['styles']);
136  
137 gulp.watch(['dist/**', 'dist/*/**'], function (file) {
138 $.livereload.changed(file);
139 });
140  
141 $.livereload.listen();
142 });
143  
144 gulp.task('build', ['scripts', 'langs', 'plugins', 'sass-dist', 'icons']);
145  
146 gulp.task('default', ['build', 'watch']);