forked from postcss/postcss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
69 lines (55 loc) · 1.86 KB
/
gulpfile.babel.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
import gulp from 'gulp';
gulp.task('clean', () => {
let del = require('del');
return del(['lib/*.js', 'postcss.js', 'build/', 'coverage/']);
});
// Build
gulp.task('compile', ['clean'], () => {
let sourcemaps = require('gulp-sourcemaps');
let babel = require('gulp-babel');
return gulp.src('lib/*.es6')
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(sourcemaps.write())
.pipe(gulp.dest('lib'));
});
gulp.task('build:lib', ['compile'], () => {
return gulp.src('lib/*.js').pipe(gulp.dest('build/lib'));
});
gulp.task('build:docs', ['clean'], () => {
let ignore = require('fs').readFileSync('.npmignore').toString()
.trim().split(/\n+/)
.concat(['.npmignore', 'index.js', 'lib/*', 'test/*',
'node_modules/**/*'])
.map( i => '!' + i );
return gulp.src(['**/*'].concat(ignore))
.pipe(gulp.dest('build'));
});
gulp.task('build', ['build:lib', 'build:docs']);
// Lint
gulp.task('lint', () => {
let eslint = require('gulp-eslint');
return gulp.src(['*.js', 'lib/*.es6', 'test/*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('spellcheck', () => {
let shell = require('gulp-shell');
return gulp.src(['*.md', 'docs/**/*.md'], { read: false })
.pipe(shell('yaspeller <%= file.path %>'));
});
// Tests
gulp.task('test', ['compile'], () => {
let ava = require('gulp-ava');
return gulp.src('test/*.js', { read: false }).pipe(ava());
});
gulp.task('integration', ['build:lib'], done => {
let postcss = require('./build/lib/postcss');
let real = require('postcss-parser-tests/real');
real(done, css => {
return postcss.parse(css).toResult({ map: { annotation: false } });
});
});
// Common
gulp.task('default', ['lint', 'spellcheck', 'test', 'integration']);