Skip to content

Commit ab49120

Browse files
committed
Require Node.js 8 and Gulp 4
Fixes #113
1 parent 83cc576 commit ab49120

File tree

5 files changed

+50
-44
lines changed

5 files changed

+50
-44
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: node_js
22
node_js:
3+
- '12'
34
- '10'
45
- '8'
5-
- '6'

index.js

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,43 @@ module.exports = options => {
1818
return;
1919
}
2020

21-
postcss(autoprefixer(options)).process(file.contents.toString(), {
22-
map: file.sourceMap ? {annotation: false} : false,
23-
from: file.path,
24-
to: file.path
25-
}).then(result => {
26-
file.contents = Buffer.from(result.css);
27-
28-
if (result.map && file.sourceMap) {
29-
const map = result.map.toJSON();
30-
map.file = file.relative;
31-
map.sources = map.sources.map(() => file.relative);
32-
applySourceMap(file, map);
21+
(async () => {
22+
try {
23+
const result = await postcss(autoprefixer(options)).process(file.contents.toString(), {
24+
map: file.sourceMap ? {annotation: false} : false,
25+
from: file.path,
26+
to: file.path
27+
});
28+
29+
file.contents = Buffer.from(result.css);
30+
31+
if (result.map && file.sourceMap) {
32+
const map = result.map.toJSON();
33+
map.file = file.relative;
34+
map.sources = map.sources.map(() => file.relative);
35+
applySourceMap(file, map);
36+
}
37+
38+
const warnings = result.warnings();
39+
40+
if (warnings.length > 0) {
41+
fancyLog('gulp-autoprefixer:', '\n ' + warnings.join('\n '));
42+
}
43+
44+
setImmediate(callback, null, file);
45+
} catch (error) {
46+
const cssError = error.name === 'CssSyntaxError';
47+
48+
if (cssError) {
49+
error.message += error.showSourceCode();
50+
}
51+
52+
// Prevent stream unhandled exception from being suppressed by Promise
53+
setImmediate(callback, new PluginError('gulp-autoprefixer', error, {
54+
fileName: file.path,
55+
showStack: !cssError
56+
}));
3357
}
34-
35-
const warnings = result.warnings();
36-
37-
if (warnings.length > 0) {
38-
fancyLog('gulp-autoprefixer:', '\n ' + warnings.join('\n '));
39-
}
40-
41-
setImmediate(callback, null, file);
42-
}).catch(error => {
43-
const cssError = error.name === 'CssSyntaxError';
44-
45-
if (cssError) {
46-
error.message += error.showSourceCode();
47-
}
48-
49-
// Prevent stream unhandled exception from being suppressed by Promise
50-
setImmediate(callback, new PluginError('gulp-autoprefixer', error, {
51-
fileName: file.path,
52-
showStack: !cssError
53-
}));
54-
});
58+
})();
5559
});
5660
};

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"url": "sindresorhus.com"
1111
},
1212
"engines": {
13-
"node": ">=6"
13+
"node": ">=8"
1414
},
1515
"scripts": {
1616
"test": "xo && ava"
@@ -30,18 +30,21 @@
3030
"postcss-runner"
3131
],
3232
"dependencies": {
33-
"autoprefixer": "^9.5.1",
33+
"autoprefixer": "^9.6.1",
3434
"fancy-log": "^1.3.2",
3535
"plugin-error": "^1.0.1",
36-
"postcss": "^7.0.2",
36+
"postcss": "^7.0.17",
3737
"through2": "^3.0.1",
3838
"vinyl-sourcemaps-apply": "^0.2.1"
3939
},
4040
"devDependencies": {
41-
"ava": "^1.4.1",
41+
"ava": "^2.3.0",
4242
"gulp-sourcemaps": "^2.6.0",
43-
"p-event": "^2.3.1",
43+
"p-event": "^4.1.0",
4444
"vinyl": "^2.1.0",
4545
"xo": "^0.24.0"
46+
},
47+
"peerDependencies": {
48+
"gulp": ">=4"
4649
}
4750
}

readme.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ $ npm install --save-dev gulp-autoprefixer
1818
const gulp = require('gulp');
1919
const autoprefixer = require('gulp-autoprefixer');
2020

21-
gulp.task('default', () =>
21+
exports.default = () => (
2222
gulp.src('src/app.css')
2323
.pipe(autoprefixer({
24-
browsers: ['last 2 versions'],
2524
cascade: false
2625
}))
2726
.pipe(gulp.dest('dist'))
@@ -31,7 +30,7 @@ gulp.task('default', () =>
3130

3231
## API
3332

34-
### autoprefixer([options])
33+
### autoprefixer(options?)
3534

3635
#### options
3736

@@ -50,7 +49,7 @@ const sourcemaps = require('gulp-sourcemaps');
5049
const autoprefixer = require('gulp-autoprefixer');
5150
const concat = require('gulp-concat');
5251

53-
gulp.task('default', () =>
52+
exports.default = () => (
5453
gulp.src('src/**/*.css')
5554
.pipe(sourcemaps.init())
5655
.pipe(autoprefixer())

test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ test('generate source maps', async t => {
2828

2929
init
3030
.pipe(autoprefixer({
31-
browsers: ['Firefox ESR']
31+
overrideBrowserslist: ['Firefox ESR']
3232
}))
3333
.pipe(write);
3434

0 commit comments

Comments
 (0)