Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Require Node.js 4
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed May 8, 2017
1 parent 4c588d2 commit 6d06065
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 42 deletions.
5 changes: 1 addition & 4 deletions .editorconfig
Expand Up @@ -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
1 change: 1 addition & 0 deletions .gitattributes
@@ -1 +1,2 @@
* text=auto
*.js text eol=lf
3 changes: 2 additions & 1 deletion .travis.yml
@@ -1,4 +1,5 @@
sudo: false
language: node_js
node_js:
- '0.12'
- '6'
- '4'
2 changes: 0 additions & 2 deletions Brocfile.js

This file was deleted.

2 changes: 2 additions & 0 deletions brocfile.js
@@ -0,0 +1,2 @@
'use strict';
module.exports = require('.')('fixture', {sourcemap: true, cascade: false});
22 changes: 11 additions & 11 deletions 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);
}
Expand All @@ -23,30 +23,30 @@ 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'));
}

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();
}

Expand Down
9 changes: 4 additions & 5 deletions package.json
Expand Up @@ -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"
Expand All @@ -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": "*"
}
}
15 changes: 7 additions & 8 deletions readme.md
Expand Up @@ -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);
```

Expand All @@ -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`<br>
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)
20 changes: 9 additions & 11 deletions 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/);
});

0 comments on commit 6d06065

Please sign in to comment.