Skip to content

Commit 541c657

Browse files
committed
do not set options.map unless --map is used
move `mapOptions` parsing to global scope make it similar to customSyntaxOptions
1 parent 89efbd4 commit 541c657

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

index.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ var customSyntaxOptions = ['syntax', 'parser', 'stringifier']
121121
return cso;
122122
}, Object.create(null));
123123

124+
125+
var mapOptions = argv.map;
126+
// treat `--map file` as `--no-map.inline`
127+
if (mapOptions === 'file') {
128+
mapOptions = { inline: false };
129+
}
130+
124131
var async = require('neo-async');
125132
var fs = require('fs');
126133
var readFile = require('read-file-stdin');
@@ -173,15 +180,10 @@ function compile(input, fn) {
173180
output = input;
174181
}
175182

176-
var map = typeof argv.map !== 'undefined' ? argv.map : false;
177-
if (map === 'file') {
178-
map = { inline:false };
179-
}
180-
181-
processCSS(processor, input, output, map, fn);
183+
processCSS(processor, input, output, fn);
182184
}
183185

184-
function processCSS(processor, input, output, map, fn) {
186+
function processCSS(processor, input, output, fn) {
185187
function doProcess(css, fn) {
186188
function onResult(result) {
187189
if (typeof result.warnings === 'function') {
@@ -192,14 +194,17 @@ function processCSS(processor, input, output, map, fn) {
192194

193195
var options = {
194196
from: input,
195-
to: output,
196-
map: map
197+
to: output
197198
};
198199

199200
Object.keys(customSyntaxOptions).forEach(function(opt) {
200201
options[opt] = customSyntaxOptions[opt];
201202
});
202203

204+
if (typeof mapOptions !== 'undefined') {
205+
options.map = mapOptions;
206+
}
207+
203208
var result = processor.process(css, options);
204209

205210
if (typeof result.then === 'function') {

0 commit comments

Comments
 (0)