Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
Fixes #110
  • Loading branch information
sindresorhus committed Apr 19, 2019
1 parent dfe3919 commit 7b080bf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
24 changes: 12 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,39 @@ const applySourceMap = require('vinyl-sourcemaps-apply');
const autoprefixer = require('autoprefixer');
const postcss = require('postcss');

module.exports = opts => {
return through.obj((file, enc, cb) => {
module.exports = options => {
return through.obj((file, encoding, callback) => {
if (file.isNull()) {
cb(null, file);
callback(null, file);
return;
}

if (file.isStream()) {
cb(new PluginError('gulp-autoprefixer', 'Streaming not supported'));
callback(new PluginError('gulp-autoprefixer', 'Streaming not supported'));
return;
}

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

if (res.map && file.sourceMap) {
const map = res.map.toJSON();
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 = res.warnings();
const warnings = result.warnings();

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

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

Expand All @@ -47,7 +47,7 @@ module.exports = opts => {
}

// Prevent stream unhandled exception from being suppressed by Promise
setImmediate(cb, new PluginError('gulp-autoprefixer', error, {
setImmediate(callback, new PluginError('gulp-autoprefixer', error, {
fileName: file.path,
showStack: !cssError
}));
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@
"postcss-runner"
],
"dependencies": {
"autoprefixer": "^9.1.3",
"autoprefixer": "^9.5.1",
"fancy-log": "^1.3.2",
"plugin-error": "^1.0.1",
"postcss": "^7.0.2",
"through2": "^2.0.0",
"vinyl-sourcemaps-apply": "^0.2.0"
"through2": "^3.0.1",
"vinyl-sourcemaps-apply": "^0.2.1"
},
"devDependencies": {
"ava": "*",
"ava": "^1.4.1",
"gulp-sourcemaps": "^2.6.0",
"p-event": "^2.1.0",
"p-event": "^2.3.1",
"vinyl": "^2.1.0",
"xo": "*"
"xo": "^0.24.0"
}
}
10 changes: 5 additions & 5 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import test from 'ava';
import Vinyl from 'vinyl';
import sourceMaps from 'gulp-sourcemaps';
import pEvent from 'p-event';
import m from '.';
import autoprefixer from '.';

test('autoprefix CSS', async t => {
const stream = m();
const stream = autoprefixer();
const data = pEvent(stream, 'data');

stream.end(new Vinyl({
Expand All @@ -27,7 +27,7 @@ test('generate source maps', async t => {
const data = pEvent(write, 'data');

init
.pipe(m({
.pipe(autoprefixer({
browsers: ['Firefox ESR']
}))
.pipe(write);
Expand All @@ -41,15 +41,15 @@ test('generate source maps', async t => {
}));

const file = await data;
t.is(file.sourceMap.mappings, 'AAAA;CACC,cAAc;CACd');
t.is(file.sourceMap.mappings, 'AAAA;CACC,aAAa;AACd');
const contents = file.contents.toString();
t.true(/flex/.test(contents));
t.true(/sourceMappingURL=data:application\/json;charset=utf8;base64/.test(contents));
});

test('read upstream source maps', async t => {
let testFile;
const stream = m();
const stream = autoprefixer();
const write = sourceMaps.write();
const sourcesContent = [
'a {\n display: flex;\n}\n',
Expand Down

0 comments on commit 7b080bf

Please sign in to comment.