Skip to content

Commit 7df69ba

Browse files
committedMay 8, 2017
ES2015ify, bump postcss, require Node.js 4
1 parent 0a92d79 commit 7df69ba

File tree

6 files changed

+48
-42
lines changed

6 files changed

+48
-42
lines changed
 

‎.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
* text=auto
2+
*.js text eol=lf

‎.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
sudo: false
22
language: node_js
33
node_js:
4-
- 'node'
4+
- '6'
5+
- '4'

‎index.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'use strict';
2-
var gutil = require('gulp-util');
3-
var through = require('through2');
4-
var applySourceMap = require('vinyl-sourcemaps-apply');
5-
var autoprefixer = require('autoprefixer');
6-
var postcss = require('postcss');
7-
8-
module.exports = function (opts) {
9-
return through.obj(function (file, enc, cb) {
2+
const gutil = require('gulp-util');
3+
const through = require('through2');
4+
const applySourceMap = require('vinyl-sourcemaps-apply');
5+
const autoprefixer = require('autoprefixer');
6+
const postcss = require('postcss');
7+
8+
module.exports = opts => {
9+
return through.obj((file, enc, cb) => {
1010
if (file.isNull()) {
1111
cb(null, file);
1212
return;
@@ -21,28 +21,28 @@ module.exports = function (opts) {
2121
map: file.sourceMap ? {annotation: false} : false,
2222
from: file.path,
2323
to: file.path
24-
}).then(function (res) {
25-
file.contents = new Buffer(res.css);
24+
}).then(res => {
25+
file.contents = Buffer.from(res.css);
2626

2727
if (res.map && file.sourceMap) {
2828
applySourceMap(file, res.map.toString());
2929
}
3030

31-
var warnings = res.warnings();
31+
const warnings = res.warnings();
3232

3333
if (warnings.length > 0) {
3434
gutil.log('gulp-autoprefixer:', '\n ' + warnings.join('\n '));
3535
}
3636

3737
setImmediate(cb, null, file);
38-
}).catch(function (err) {
39-
var cssError = err.name === 'CssSyntaxError';
38+
}).catch(err => {
39+
const cssError = err.name === 'CssSyntaxError';
4040

4141
if (cssError) {
4242
err.message += err.showSourceCode();
4343
}
4444

45-
// prevent stream unhandled exception from being suppressed by Promise
45+
// Prevent stream unhandled exception from being suppressed by Promise
4646
setImmediate(cb, new gutil.PluginError('gulp-autoprefixer', err, {
4747
fileName: file.path,
4848
showStack: !cssError

‎package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"url": "sindresorhus.com"
1111
},
1212
"engines": {
13-
"node": ">=0.12.0"
13+
"node": ">=4"
1414
},
1515
"scripts": {
1616
"test": "xo && mocha"
@@ -32,12 +32,12 @@
3232
"dependencies": {
3333
"autoprefixer": "^7.0.0",
3434
"gulp-util": "^3.0.0",
35-
"postcss": "^5.0.4",
35+
"postcss": "^6.0.1",
3636
"through2": "^2.0.0",
3737
"vinyl-sourcemaps-apply": "^0.2.0"
3838
},
3939
"devDependencies": {
40-
"gulp-sourcemaps": "^1.1.1",
40+
"gulp-sourcemaps": "^2.6.0",
4141
"mocha": "*",
4242
"xo": "*"
4343
}

‎readme.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
55
*Issues with the output should be reported on the Autoprefixer [issue tracker](https://github.com/postcss/autoprefixer/issues).*
66

7+
78
---
89

9-
<p align="center"><b>🔥 Want to strengthen your core JavaScript skills and master ES6?</b><br>I would personally recommend this awesome <a href="https://ES6.io/friend/AWESOME">ES6 course</a> by Wes Bos.</p>
10+
<p align="center">👾</p>
11+
<p align="center"><b>Improve your JavaScript skills with this awesome <a href="https://ES6.io/friend/AWESOME">ES6 course</a> by Wes Bos.</b><br>Try his free <a href="https://javascript30.com/friend/AWESOME">JavaScript 30 course</a> for a taste of what to expect. You might also like his <a href="https://ReactForBeginners.com/friend/AWESOME">React</a> & <a href="https://SublimeTextBook.com/friend/AWESOME">Sublime</a> course.</p>
1012

1113
---
1214

@@ -41,12 +43,14 @@ gulp.task('default', () =>
4143

4244
#### options
4345

46+
Type: `Object`
47+
4448
See the Autoprefixer [options](https://github.com/postcss/autoprefixer#options).
4549

4650

4751
## Source Maps
4852

49-
Use [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) like this:
53+
Use [gulp-sourcemaps](https://github.com/gulp-sourcemaps/gulp-sourcemaps) like this:
5054

5155
```js
5256
const gulp = require('gulp');

‎test.js

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/* eslint-env mocha */
22
'use strict';
3-
var path = require('path');
4-
var assert = require('assert');
5-
var gutil = require('gulp-util');
6-
var sourceMaps = require('gulp-sourcemaps');
7-
var autoprefixer = require('./');
3+
const path = require('path');
4+
const assert = require('assert');
5+
const gutil = require('gulp-util');
6+
const sourceMaps = require('gulp-sourcemaps');
7+
const autoprefixer = require('./');
88

9-
it('should autoprefix CSS', function (cb) {
10-
var stream = autoprefixer();
9+
it('should autoprefix CSS', cb => {
10+
const stream = autoprefixer();
1111

12-
stream.on('data', function (file) {
12+
stream.on('data', file => {
1313
assert(/-/.test(file.contents.toString()));
1414
assert.equal(file.relative, 'fixture.css');
1515
});
@@ -20,25 +20,25 @@ it('should autoprefix CSS', function (cb) {
2020
cwd: __dirname,
2121
base: path.join(__dirname, 'fixture'),
2222
path: path.join(__dirname, 'fixture', 'fixture.css'),
23-
contents: new Buffer('a {\n\tdisplay: flex;\n}')
23+
contents: Buffer.from('a {\n\tdisplay: flex;\n}')
2424
}));
2525

2626
stream.end();
2727
});
2828

29-
it('should generate source maps', function (cb) {
30-
var init = sourceMaps.init();
31-
var write = sourceMaps.write();
29+
it('should generate source maps', cb => {
30+
const init = sourceMaps.init();
31+
const write = sourceMaps.write();
3232

3333
init
3434
.pipe(autoprefixer({
3535
browsers: ['Firefox ESR']
3636
}))
3737
.pipe(write);
3838

39-
write.on('data', function (file) {
39+
write.on('data', file => {
4040
assert.equal(file.sourceMap.mappings, 'AAAA;CACC,cAAc;CACd');
41-
var contents = file.contents.toString();
41+
const contents = file.contents.toString();
4242
assert(/flex/.test(contents));
4343
assert(/sourceMappingURL=data:application\/json;charset=utf8;base64/.test(contents));
4444
cb();
@@ -48,25 +48,25 @@ it('should generate source maps', function (cb) {
4848
cwd: __dirname,
4949
base: path.join(__dirname, 'fixture'),
5050
path: path.join(__dirname, 'fixture', 'fixture.css'),
51-
contents: new Buffer('a {\n\tdisplay: flex;\n}'),
51+
contents: Buffer.from('a {\n\tdisplay: flex;\n}'),
5252
sourceMap: ''
5353
}));
5454

5555
init.end();
5656
});
5757

58-
it('should read upstream source maps', function (cb) {
59-
var testFile;
60-
var stream = autoprefixer();
61-
var write = sourceMaps.write();
62-
var sourcesContent = [
58+
it('should read upstream source maps', cb => {
59+
let testFile;
60+
const stream = autoprefixer();
61+
const write = sourceMaps.write();
62+
const sourcesContent = [
6363
'a {\n display: flex;\n}\n',
6464
'a {\n\tdisplay: flex;\n}\n'
6565
];
6666

6767
stream.pipe(write);
6868

69-
write.on('data', function (file) {
69+
write.on('data', file => {
7070
assert.equal(file.sourceMap.sourcesContent[0], sourcesContent[0]);
7171
assert.equal(file.sourceMap.sourcesContent[1], sourcesContent[1]);
7272
cb();
@@ -77,7 +77,7 @@ it('should read upstream source maps', function (cb) {
7777
cwd: __dirname,
7878
base: path.join(__dirname, 'fixture'),
7979
path: path.join(__dirname, 'fixture', 'fixture.css'),
80-
contents: new Buffer('a {\n\tdisplay: flex;\n}\n')
80+
contents: Buffer.from('a {\n\tdisplay: flex;\n}\n')
8181
}),
8282
testFile.sourceMap = {
8383
version: 3,

0 commit comments

Comments
 (0)
Please sign in to comment.