Skip to content

Commit b437782

Browse files
See #61 - source maps not being built in batch mode.
Batch mode works without setting `--output` option and CLI wrongly assumed an output is needed for source maps to work.
1 parent faf9ed0 commit b437782

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ function cli(process, beforeMinifyCallback) {
115115
options.sourceMap = true;
116116
}
117117

118-
if (options.sourceMap && !options.output) {
118+
if (options.sourceMap && !options.output && !options.batch) {
119119
outputFeedback(['Source maps will not be built because you have not specified an output file.'], true);
120120
options.sourceMap = false;
121121
}

test/binary-test.js

+45
Original file line numberDiff line numberDiff line change
@@ -903,4 +903,49 @@ vows.describe('cleancss')
903903
}
904904
})
905905
})
906+
.addBatch({
907+
'batch processing with source maps': binaryContext('-b ./test/fixtures-batch-7/partials/\\*\\*/*.css --source-map', {
908+
'setup': function () {
909+
execSync('cp -fr test/fixtures test/fixtures-batch-7');
910+
execSync('rm -fr test/fixtures-batch-7/partials/extra/four.css');
911+
execSync('touch test/fixtures-batch-7/partials/extra/four.css');
912+
},
913+
'does not raise an error': function (error, stdout, stderr) {
914+
assert.equal(stderr, '');
915+
},
916+
'creates source map files': function () {
917+
assert.isTrue(fs.existsSync('test/fixtures-batch-7/partials/extra/three-min.css.map'));
918+
assert.isTrue(fs.existsSync('test/fixtures-batch-7/partials/one-min.css.map'));
919+
assert.isTrue(fs.existsSync('test/fixtures-batch-7/partials/two-min.css.map'));
920+
assert.isTrue(fs.existsSync('test/fixtures-batch-7/partials/quoted-svg-min.css.map'));
921+
assert.isTrue(fs.existsSync('test/fixtures-batch-7/partials/five-min.css.map'));
922+
},
923+
'teardown': function () {
924+
execSync('rm -fr test/fixtures-batch-7');
925+
}
926+
})
927+
})
928+
.addBatch({
929+
'batch processing with source maps and output as a path': binaryContext('-b ./test/fixtures-batch-8/partials/\\*\\*/*.css --source-map -o test/fixtures-batch-8-output', {
930+
'setup': function () {
931+
execSync('cp -fr test/fixtures test/fixtures-batch-8');
932+
execSync('rm -fr test/fixtures-batch-8/partials/extra/four.css');
933+
execSync('touch test/fixtures-batch-8/partials/extra/four.css');
934+
},
935+
'does not raise an error': function (error, stdout, stderr) {
936+
assert.equal(stderr, '');
937+
},
938+
'creates source map files': function () {
939+
assert.isTrue(fs.existsSync('test/fixtures-batch-8-output/extra/three-min.css.map'));
940+
assert.isTrue(fs.existsSync('test/fixtures-batch-8-output/one-min.css.map'));
941+
assert.isTrue(fs.existsSync('test/fixtures-batch-8-output/two-min.css.map'));
942+
assert.isTrue(fs.existsSync('test/fixtures-batch-8-output/quoted-svg-min.css.map'));
943+
assert.isTrue(fs.existsSync('test/fixtures-batch-8-output/five-min.css.map'));
944+
},
945+
'teardown': function () {
946+
execSync('rm -fr test/fixtures-batch-8');
947+
execSync('rm -fr test/fixtures-batch-8-output');
948+
}
949+
})
950+
})
906951
.export(module);

0 commit comments

Comments
 (0)