From 8bc518a26b85fa313fe58a096efd6148e7c45b9c Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Fri, 16 Mar 2018 14:37:06 +0200 Subject: [PATCH] Ensure that default includeDefaultStyles has been configured before using it --- lib/styleguide.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/styleguide.js b/lib/styleguide.js index c7786422..91b6d624 100644 --- a/lib/styleguide.js +++ b/lib/styleguide.js @@ -254,15 +254,6 @@ function filterFiles(files, filter) { } module.exports.generate = function(options) { - try { - if (options.includeDefaultStyles) { - fs.copySync(distPath + '/css/withstyles/styleguide-app.css', distPath + '/css/styleguide-app.css'); - } else { - fs.copySync(distPath + '/css/withoutstyles/styleguide-app.css', distPath + '/css/styleguide-app.css'); - } - } catch (err) { - console.log('ERROR: Unable to exclude default styles.'); - } var opt = common.sanitizeOptions(options), filesBuffer = {}, throughOpts = { @@ -278,6 +269,16 @@ module.exports.generate = function(options) { ); sgOptions = opt; // Copy options into global + try { + if (opt.includeDefaultStyles) { + fs.copySync(distPath + '/css/withstyles/styleguide-app.css', distPath + '/css/styleguide-app.css'); + } else { + fs.copySync(distPath + '/css/withoutstyles/styleguide-app.css', distPath + '/css/styleguide-app.css'); + } + } catch (err) { + console.log('ERROR: Unable to exclude default styles.'); + } + function bufferFileContents(file, enc, done) { if (file.isNull()) { return; @@ -582,4 +583,4 @@ function startServer(options) { return serverInstance[options.port]; } -module.exports.addSection = addSection; \ No newline at end of file +module.exports.addSection = addSection;