File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,8 +4,6 @@ const fs = require('fs-promise')
44const path = require ( 'path' )
55
66const stdin = require ( 'get-stdin' )
7- const Readable = require ( 'stream' ) . Readable
8-
97const chalk = require ( 'chalk' )
108const ora = require ( 'ora' )
119const globber = require ( 'globby' )
@@ -217,6 +215,12 @@ function css (css, file) {
217215 options . to = path . resolve ( options . to )
218216 }
219217
218+ // Can't use external sourcemaps when writing to stdout:
219+ if ( ! options . to && config . options . map && ! config . options . map . inline ) {
220+ spinner . fail ( )
221+ error ( 'Cannot output external sourcemaps when writing to stdout' )
222+ }
223+
220224 return postcss ( config . plugins )
221225 . process ( css , options )
222226 . then ( ( result ) => {
@@ -242,15 +246,7 @@ function css (css, file) {
242246 )
243247 )
244248 }
245- } else {
246- const $ = new Readable ( { read : ( chunk ) => chunk } )
247-
248- result . map
249- ? $ . push ( result . css , result . map )
250- : $ . push ( result . css )
251-
252- $ . pipe ( process . stdout )
253- }
249+ } else process . stdout . write ( result . css , 'utf8' )
254250
255251 return Promise . all ( tasks )
256252 . then ( ( ) => {
Original file line number Diff line number Diff line change @@ -24,6 +24,14 @@ test('multiple input files && writing to stdout', (t) => {
2424 } )
2525} )
2626
27+ test ( '--map && writing to stdout' , ( t ) => {
28+ return cli ( [ 'test/fixtures/a.css' , '--map' ] )
29+ . then ( ( { err, code } ) => {
30+ t . is ( code , 1 , 'expected non-zero error code' )
31+ t . regex ( err , / C a n n o t o u t p u t e x t e r n a l s o u r c e m a p s w h e n w r i t i n g t o s t d o u t / )
32+ } )
33+ } )
34+
2735test ( 'invalid --config' , ( t ) => {
2836 return cli (
2937 [
You can’t perform that action at this time.
0 commit comments