Skip to content

String #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .coveralls.yml

This file was deleted.

12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ var fixtures = path.resolve.bind(path, __dirname, 'fixtures')

postcss(url([
[ util.inline, { maxSize: 5 } ],
[ util.copy, { assetOutFolder: fixtures('build', 'images') } ],
// equivalent with util.copy
[ 'copy', { assetOutFolder: fixtures('build', 'images') } ],
]))
.process(
'.a{ background-image: url(images/octocat_setup.png); }',
Expand All @@ -41,7 +42,11 @@ Type: `Array`

Default: `[ util.rebase ]`

An array of transforms
An array of transforms.

If an element is not a function,
it should be the name of a method exported by `util`:
`'copy'`, `'inline'`, `'rebase'`.

### transforms

Expand All @@ -52,7 +57,8 @@ Signature: `transformFn(result, ...args)`
Function to transform url,
through modifying `result.url`

If `Array`, `args` will be the elements from the second.
If `Array`, the first element should be the transform function,
and elements after the first will be treated as its arguments `args`.

#### result

Expand Down
4 changes: 4 additions & 0 deletions lib/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const Url = require('url')
const path = require('path')
const Asset = require('./asset')
const util = require('./util')

class Result {
constructor(url, opts) {
Expand Down Expand Up @@ -46,6 +47,9 @@ class Result {
})
return trs.reduce(function (p, tr) {
return p.then(function () {
if (typeof tr[0] === 'string') {
tr[0] = util[tr[0]]
}
let r = tr[0].apply(null, tr.slice(1))
if (r && typeof r.then === 'function') {
return r
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"main": "index.js",
"scripts": {
"test": "npm run lint && tap test/*.js",
"cov": "npm run lint && tap --cov test/*.js",
"lint": "eslint *.js 'lib/**/*.js' test/*.js bin/*.js",
"coveralls": "COVERALLS_REPO_TOKEN=REPO_TOKEN tap test/*.js"
"coveralls": "COVERALLS_REPO_TOKEN=m8BySBat6AaALacZWXaSBWhuVYOo6Yd7y tap test/*.js"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion test/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test('custom', function(t) {

result.url = path.join(base, path.basename(result.url))
}, 'i'],
util.copy,
'copy',
])
let body = '.a{ background-image: url(images/octocat_setup.png) url(images/octocat_fork.png); }'
let expectedBody = [ '.a{background-image:url(', ')url(i/octocat_fork.png);}' ]
Expand Down