-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.babel.js
77 lines (64 loc) · 2.08 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
70
71
72
73
74
75
76
77
import gulp from 'gulp';
gulp.task('clean', () => {
let del = require('del');
return del(['build/']);
});
// Build
gulp.task('build:lib', ['clean'], () => {
let babel = require('gulp-babel');
return gulp.src('lib/*.es6')
.pipe(babel())
.pipe(gulp.dest('build/lib'));
});
gulp.task('build:docs', ['clean'], () => {
let ignore = require('fs').readFileSync('.npmignore').toString()
.trim().split(/\n+/)
.concat(['.npmignore', 'package.json', 'index.js'])
.map( i => '!' + i );
return gulp.src(['*'].concat(ignore))
.pipe(gulp.dest('build'));
});
gulp.task('build:package', ['clean'], () => {
let editor = require('gulp-json-editor');
gulp.src('./package.json')
.pipe(editor( json => {
json.main = 'lib/strip-inline-comments';
for ( let i in json.dependencies ) {
if ( /^babel-/.test(i) ) {
json.devDependencies[i] = json.dependencies[i];
delete json.dependencies[i];
}
}
return json;
}))
.pipe(gulp.dest('build'));
});
gulp.task('build', ['build:lib', 'build:docs', 'build:package']);
// Lint
gulp.task('lint', () => {
let eslint = require('gulp-eslint');
return gulp.src(['*.js', 'lib/*.es6', 'test/*.es6'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
// Test
gulp.task('test', () => {
require('babel-core/register')({ extensions: ['.es6'], ignore: false });
let mocha = require('gulp-mocha');
return gulp.src('test/*.es6', { read: false }).pipe(mocha());
});
gulp.task('integration', done => {
require('babel-core/register')({ extensions: ['.es6'], ignore: false });
let postcss = require('postcss');
let real = require('postcss-parser-tests/real');
let scss = require('postcss-scss');
real(done, css => {
return postcss().process(css, {
parser: scss,
map: { annotation: false }
});
});
});
// Common
gulp.task('default', ['lint', 'test']);