Skip to content

Commit cfd6374

Browse files
committed
Fixes #30
1 parent 7eb3ca8 commit cfd6374

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ module.exports = function (processors, options) {
3434
}
3535
}
3636

37-
opts.from = opts.to = file.path
37+
opts.from = file.path
38+
opts.to = opts.to || file.path
3839

3940
// Generate separate source map for gulp-sourcemap
4041
if (file.sourceMap) {

test.js

+31-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global it, afterEach, describe, Promise */
1+
/* global it, afterEach, beforeEach, describe, Promise */
22

33
require('es6-promise').polyfill()
44
var assert = require('assert')
@@ -123,8 +123,8 @@ describe('PostCSS Guidelines', function () {
123123
}
124124
}
125125
var postcssStub = {
126-
use: sandbox.stub()
127-
, process: sandbox.stub()
126+
use: function () {}
127+
, process: function () {}
128128
}
129129
var postcss = proxyquire('./index', {
130130
postcss: function () {
@@ -133,6 +133,10 @@ describe('PostCSS Guidelines', function () {
133133
, 'postcss/lib/css-syntax-error': CssSyntaxError
134134
})
135135

136+
beforeEach(function () {
137+
sandbox.stub(postcssStub, 'use')
138+
sandbox.stub(postcssStub, 'process')
139+
})
136140

137141
afterEach(function () {
138142
sandbox.restore()
@@ -151,7 +155,8 @@ describe('PostCSS Guidelines', function () {
151155
}))
152156

153157
stream.on('data', function () {
154-
postcssStub.process.calledWith('a {}', {from: cssPath, to: cssPath})
158+
assert.equal(postcssStub.process.getCall(0).args[1].to, cssPath)
159+
assert.equal(postcssStub.process.getCall(0).args[1].from, cssPath)
155160
cb()
156161
})
157162

@@ -164,6 +169,28 @@ describe('PostCSS Guidelines', function () {
164169

165170
})
166171

172+
it('should allow override of `to` processing option', function (cb) {
173+
174+
var stream = postcss([ doubler ], {to: 'overriden'})
175+
postcssStub.process.returns(Promise.resolve({
176+
css: ''
177+
, warnings: function () {
178+
return []
179+
}
180+
}))
181+
182+
stream.on('data', function () {
183+
assert.equal(postcssStub.process.getCall(0).args[1].to, 'overriden')
184+
cb()
185+
})
186+
187+
stream.write(new gutil.File({
188+
contents: new Buffer('a {}')
189+
}))
190+
191+
stream.end()
192+
193+
})
167194

168195
it('should not output js stack trace for `CssSyntaxError`', function (cb) {
169196

0 commit comments

Comments
 (0)