diff --git a/.editorconfig b/.editorconfig index 8f9d77e..1c6314a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,9 +7,6 @@ charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true -[{package.json,*.yml}] +[*.yml] indent_style = space indent_size = 2 - -[*.md] -trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes index 176a458..391f0a4 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ * text=auto +*.js text eol=lf diff --git a/.travis.yml b/.travis.yml index 9134a0c..b18bae5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ sudo: false language: node_js node_js: - - '0.12' + - '6' + - '4' diff --git a/Brocfile.js b/Brocfile.js deleted file mode 100644 index e4685c0..0000000 --- a/Brocfile.js +++ /dev/null @@ -1,2 +0,0 @@ -'use strict'; -module.exports = require('./')('fixture', {sourcemap: true, cascade: false}); diff --git a/brocfile.js b/brocfile.js new file mode 100644 index 0000000..0030123 --- /dev/null +++ b/brocfile.js @@ -0,0 +1,2 @@ +'use strict'; +module.exports = require('.')('fixture', {sourcemap: true, cascade: false}); diff --git a/index.js b/index.js index 608ae83..0371e92 100644 --- a/index.js +++ b/index.js @@ -1,11 +1,11 @@ 'use strict'; -var Filter = require('broccoli-persistent-filter'); -var objectAssign = require('object-assign'); -var postcss = require('postcss'); -var autoprefixer = require('autoprefixer'); +const Filter = require('broccoli-persistent-filter'); +const postcss = require('postcss'); +const autoprefixer = require('autoprefixer'); function AutoprefixerFilter(inputTree, _options) { - var options = _options || {}; + const options = _options || {}; + if (!(this instanceof AutoprefixerFilter)) { return new AutoprefixerFilter(inputTree, _options); } @@ -23,20 +23,20 @@ AutoprefixerFilter.prototype.extensions = ['css']; AutoprefixerFilter.prototype.targetExtension = 'css'; AutoprefixerFilter.prototype.processString = function (str, relativePath) { - var opts = objectAssign({ + const opts = Object.assign({ from: relativePath, to: relativePath }, this.options); - // support explicit override of inline sourcemaps + // Support explicit override of inline sourcemaps if (opts.sourcemap !== null || opts.sourcemap !== undefined) { opts.map = opts.sourcemap ? 'inline' : false; } return postcss(autoprefixer(opts)) .process(str, opts) - .then(function (result) { - var warnings = result.warnings(); + .then(result => { + const warnings = result.warnings(); if (warnings.length > 0) { console.error(warnings.join('\n')); @@ -44,9 +44,9 @@ AutoprefixerFilter.prototype.processString = function (str, relativePath) { return result.css; }) - .catch(function (err) { + .catch(err => { if (err.name === 'CssSyntaxError') { - // TODO: find a way to hide the stack so to adhere to the PostCSS guidelines + // TODO: Find a way to hide the stack so to adhere to the PostCSS guidelines err.message += err.showSourceCode(); } diff --git a/package.json b/package.json index b805582..d99db5a 100644 --- a/package.json +++ b/package.json @@ -10,10 +10,10 @@ "url": "sindresorhus.com" }, "engines": { - "node": ">=0.12.0" + "node": ">=4" }, "scripts": { - "test": "xo && broccoli build temp && mocha" + "test": "xo && broccoli build temp && ava" }, "files": [ "index.js" @@ -32,14 +32,13 @@ "dependencies": { "autoprefixer": "^7.0.0", "broccoli-persistent-filter": "^1.1.6", - "object-assign": "^4.0.1", "postcss": "^6.0.1" }, "devDependencies": { + "ava": "*", "broccoli": "^1.1.1", "broccoli-cli": "^1.0.0", - "mocha": "*", - "rimraf": "^2.2.6", + "del": "^2.2.2", "xo": "*" } } diff --git a/readme.md b/readme.md index 3d79b24..2b541ab 100644 --- a/readme.md +++ b/readme.md @@ -15,7 +15,7 @@ $ npm install --save-dev broccoli-autoprefixer ## Usage ```js -var autoprefixer = require('broccoli-autoprefixer'); +const autoprefixer = require('broccoli-autoprefixer'); tree = autoprefixer(tree, options); ``` @@ -26,25 +26,24 @@ tree = autoprefixer(tree, options); #### options +Type: `Object` + See the Autoprefixer [options](https://github.com/postcss/autoprefixer#options). In addition, you can set this option: ##### sourcemap -Type: `boolean` +Type: `boolean`
Default: `true` if the input has a sourcemap, otherwise `false` Set to `true` to include a base64-encoded sourcemap at the end of the output. -If a sourcemap already exists in the input, Autoprefixer will automatically -include an updated sourcemap in the output. Set this value to `false` to -strip out the sourcemap entirely. +If a sourcemap already exists in the input, Autoprefixer will automatically include an updated sourcemap in the output. Set this value to `false` to strip out the sourcemap entirely. -If you'd like to extract the inline sourcemap from the output, consider using a -tool like [broccoli-source-map](https://github.com/myfreeweb/broccoli-source-map). +If you'd like to extract the inline sourcemap from the output, consider using a tool like [`broccoli-source-map`](https://github.com/myfreeweb/broccoli-source-map). ## License -MIT © [Sindre Sorhus](http://sindresorhus.com) +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/test.js b/test.js index 0216675..8fc8ee9 100644 --- a/test.js +++ b/test.js @@ -1,15 +1,13 @@ -/* eslint-env mocha */ -'use strict'; -var assert = require('assert'); -var fs = require('fs'); -var rimraf = require('rimraf'); +import fs from 'fs'; +import test from 'ava'; +import del from 'del'; -afterEach(function () { - rimraf.sync('temp'); +test.afterEach(() => { + del.sync('temp'); }); -it('should prefix CSS', function () { - var f = fs.readFileSync('temp/fixture.css', 'utf8'); - assert(/:-webkit-full-screen/.test(f), f); - assert(/sourceMappingURL=data:application/.test(f)); +test('prefix CSS', t => { + const f = fs.readFileSync('temp/fixture.css', 'utf8'); + t.regex(f, /:-webkit-full-screen/); + t.regex(f, /sourceMappingURL=data:application/); });