From 234d7969191b17163671af0eb5753b000519f410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bachelier?= Date: Tue, 14 Apr 2015 01:00:36 +0200 Subject: [PATCH] remove necessity for specifying empty post in flow Fix #249 and #442 --- tasks/usemin.js | 19 +++++++++++++++---- test/test-usemin-prepare.js | 9 +++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/tasks/usemin.js b/tasks/usemin.js index 21ad81b..83b475e 100644 --- a/tasks/usemin.js +++ b/tasks/usemin.js @@ -16,12 +16,23 @@ var getFlowFromConfig = function (config, target) { post: {} }); if (config.options && config.options.flow) { + var steps; + var post; + if (config.options.flow[target]) { - flow.setSteps(config.options.flow[target].steps); - flow.setPost(config.options.flow[target].post); + steps = config.options.flow[target].steps; + post = config.options.flow[target].post; } else { - flow.setSteps(config.options.flow.steps); - flow.setPost(config.options.flow.post); + steps = config.options.flow.steps; + post = config.options.flow.post; + } + + if (steps) { + flow.setSteps(steps); + } + + if (post) { + flow.setPost(post); } } return flow; diff --git a/test/test-usemin-prepare.js b/test/test-usemin-prepare.js index 0dee425..90a2e9f 100644 --- a/test/test-usemin-prepare.js +++ b/test/test-usemin-prepare.js @@ -225,8 +225,7 @@ describe('useminPrepare', function () { flow: { steps: { js: ['uglify'] - }, - post: {} + } } } }); @@ -257,8 +256,7 @@ describe('useminPrepare', function () { html: { steps: { js: ['uglify'] - }, - post: {} + } } } } @@ -302,8 +300,7 @@ describe('useminPrepare', function () { flow: { steps: { js: [copy] - }, - post: {} + } } } });