forked from postcss/autoprefixer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
87 lines (70 loc) · 2.47 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
81
82
83
84
85
86
87
var gulp = require('gulp');
var path = require('path');
var fs = require('fs-extra');
gulp.task('clean', function (done) {
fs.remove(path.join(__dirname, 'autoprefixer.js'), function () {
fs.remove(path.join(__dirname, 'build'), done);
});
});
gulp.task('build:lib', ['clean'], function () {
var coffee = require('gulp-coffee');
return gulp.src(['{lib,data}/**/*.coffee'])
.pipe(coffee())
.pipe(gulp.dest('build/'));
});
gulp.task('build:docs', ['clean'], function () {
var ignore = require('fs').readFileSync('.npmignore').toString()
.trim().split(/\n+/)
.concat(['.npmignore', 'index.js', 'package.json', 'logo.svg'])
.map(function (i) {
return '!' + i;
});
return gulp.src(['*'].concat(ignore))
.pipe(gulp.dest('build'));
});
gulp.task('build:package', ['clean'], function () {
var editor = require('gulp-json-editor');
return gulp.src('./package.json')
.pipe(editor(function (json) {
json.main = 'lib/autoprefixer';
json.devDependencies['coffee-script'] =
json.dependencies['coffee-script'];
delete json.dependencies['coffee-script'];
return json;
}))
.pipe(gulp.dest('build'));
});
gulp.task('build', ['build:lib', 'build:docs', 'build:package']);
gulp.task('standalone', ['build:lib'], function (done) {
var builder = require('browserify')({
basedir: path.join(__dirname, 'build'),
standalone: 'autoprefixer'
});
builder.add('./lib/autoprefixer.js');
builder.bundle(function (error, build) {
if ( error ) throw error;
fs.removeSync(path.join(__dirname, 'build'));
var rails = path.join(__dirname, '..', 'autoprefixer-rails',
'vendor', 'autoprefixer.js');
if ( fs.existsSync(rails) ) {
fs.writeFileSync(rails, build);
} else {
fs.writeFileSync(path.join(__dirname, 'autoprefixer.js'), build);
}
done();
});
});
gulp.task('lint', function () {
var eslint = require('gulp-eslint');
return gulp.src(['index.js', 'gulpfile.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('test', function () {
require('coffee-script').register();
require('should');
var mocha = require('gulp-mocha');
return gulp.src('test/*.coffee', { read: false }).pipe(mocha());
});
gulp.task('default', ['lint', 'test']);