Skip to content

Commit a25a5f8

Browse files
Fixes #36 - automatically creates missing output directories.
1 parent 50854f9 commit a25a5f8

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

Diff for: History.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Bumps clean-css dependency to 5.0.
66
* Bumps commander dependency to 7.0.
77
* Fixed issue [#18](https://github.com/jakubpawlowicz/clean-css-cli/issues/18) - allows batch processing of input files.
8+
* Fixed issue [#36](https://github.com/jakubpawlowicz/clean-css-cli/issues/36) - automatically creates missing output directories.
89

910
[4.3.0 / 2019-04-06](https://github.com/jakubpawlowicz/clean-css-cli/compare/4.2...v4.3.0)
1011
==================

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ clean-css-cli 5.0 introduces the following changes / features:
6666

6767
* adds `--batch` option (off by default) which processes input files one by one without joining them together;
6868
* adds `--batch-suffix` option to specify what gets appended to output filename in batch mode;
69+
* automatically creates missing output directories;
6970
* clean-css 5.0 with loads of bugfixes;
7071
* drops official support for Node.js 4, 6, and 8;
7172
* `--skip-rebase` option has been removed as rebasing URLs is disabled by default now

Diff for: index.js

+1
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ function getSourceMapContent(sourceMapPath) {
349349

350350
function output(process, outputPath, minified) {
351351
if (outputPath) {
352+
fs.mkdirSync(path.dirname(outputPath), {recursive: true});
352353
fs.writeFileSync(outputPath, minified, 'utf8');
353354
} else {
354355
process.stdout.write(minified);

Diff for: test/binary-test.js

+9
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,15 @@ vows.describe('cleancss')
196196
teardown: function () {
197197
deleteFile('./reset1-min.css');
198198
}
199+
}),
200+
'to file when target path does not exist': binaryContext('-o ./test/fixtures-temp/reset-min.css ./test/fixtures/reset.css', {
201+
'should create a directory and optimized file': function () {
202+
assert.isTrue(fs.existsSync('test/fixtures-temp'));
203+
assert.isTrue(fs.existsSync('test/fixtures-temp/reset-min.css'));
204+
},
205+
teardown: function () {
206+
exec('rm -rf test/fixtures-temp');
207+
}
199208
})
200209
})
201210
.addBatch({

0 commit comments

Comments
 (0)