Skip to content

Commit

Permalink
Require Node.js 8 and Gulp 4
Browse files Browse the repository at this point in the history
Fixes #113
  • Loading branch information
sindresorhus committed Aug 18, 2019
1 parent 83cc576 commit ab49120
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: node_js
node_js:
- '12'
- '10'
- '8'
- '6'
70 changes: 37 additions & 33 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,43 @@ module.exports = options => {
return;
}

postcss(autoprefixer(options)).process(file.contents.toString(), {
map: file.sourceMap ? {annotation: false} : false,
from: file.path,
to: file.path
}).then(result => {
file.contents = Buffer.from(result.css);

if (result.map && file.sourceMap) {
const map = result.map.toJSON();
map.file = file.relative;
map.sources = map.sources.map(() => file.relative);
applySourceMap(file, map);
(async () => {
try {
const result = await postcss(autoprefixer(options)).process(file.contents.toString(), {
map: file.sourceMap ? {annotation: false} : false,
from: file.path,
to: file.path
});

file.contents = Buffer.from(result.css);

if (result.map && file.sourceMap) {
const map = result.map.toJSON();
map.file = file.relative;
map.sources = map.sources.map(() => file.relative);
applySourceMap(file, map);
}

const warnings = result.warnings();

if (warnings.length > 0) {
fancyLog('gulp-autoprefixer:', '\n ' + warnings.join('\n '));
}

setImmediate(callback, null, file);
} catch (error) {
const cssError = error.name === 'CssSyntaxError';

if (cssError) {
error.message += error.showSourceCode();
}

// Prevent stream unhandled exception from being suppressed by Promise
setImmediate(callback, new PluginError('gulp-autoprefixer', error, {
fileName: file.path,
showStack: !cssError
}));
}

const warnings = result.warnings();

if (warnings.length > 0) {
fancyLog('gulp-autoprefixer:', '\n ' + warnings.join('\n '));
}

setImmediate(callback, null, file);
}).catch(error => {
const cssError = error.name === 'CssSyntaxError';

if (cssError) {
error.message += error.showSourceCode();
}

// Prevent stream unhandled exception from being suppressed by Promise
setImmediate(callback, new PluginError('gulp-autoprefixer', error, {
fileName: file.path,
showStack: !cssError
}));
});
})();
});
};
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
"node": ">=8"
},
"scripts": {
"test": "xo && ava"
Expand All @@ -30,18 +30,21 @@
"postcss-runner"
],
"dependencies": {
"autoprefixer": "^9.5.1",
"autoprefixer": "^9.6.1",
"fancy-log": "^1.3.2",
"plugin-error": "^1.0.1",
"postcss": "^7.0.2",
"postcss": "^7.0.17",
"through2": "^3.0.1",
"vinyl-sourcemaps-apply": "^0.2.1"
},
"devDependencies": {
"ava": "^1.4.1",
"ava": "^2.3.0",
"gulp-sourcemaps": "^2.6.0",
"p-event": "^2.3.1",
"p-event": "^4.1.0",
"vinyl": "^2.1.0",
"xo": "^0.24.0"
},
"peerDependencies": {
"gulp": ">=4"
}
}
7 changes: 3 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ $ npm install --save-dev gulp-autoprefixer
const gulp = require('gulp');
const autoprefixer = require('gulp-autoprefixer');

gulp.task('default', () =>
exports.default = () => (
gulp.src('src/app.css')
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(gulp.dest('dist'))
Expand All @@ -31,7 +30,7 @@ gulp.task('default', () =>

## API

### autoprefixer([options])
### autoprefixer(options?)

#### options

Expand All @@ -50,7 +49,7 @@ const sourcemaps = require('gulp-sourcemaps');
const autoprefixer = require('gulp-autoprefixer');
const concat = require('gulp-concat');

gulp.task('default', () =>
exports.default = () => (
gulp.src('src/**/*.css')
.pipe(sourcemaps.init())
.pipe(autoprefixer())
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test('generate source maps', async t => {

init
.pipe(autoprefixer({
browsers: ['Firefox ESR']
overrideBrowserslist: ['Firefox ESR']
}))
.pipe(write);

Expand Down

0 comments on commit ab49120

Please sign in to comment.