From e0f744d637bc91cd3185142a1776f49583b65699 Mon Sep 17 00:00:00 2001 From: Chris Brame Date: Wed, 7 Nov 2018 03:07:17 -0500 Subject: [PATCH] fix(sass): not compiling for install server --- src/sass/buildsass.js | 29 +++++++++++++++++++++++------ src/webserver.js | 18 ++++++++++++------ 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/src/sass/buildsass.js b/src/sass/buildsass.js index 58a69f181..b50ca776d 100644 --- a/src/sass/buildsass.js +++ b/src/sass/buildsass.js @@ -13,6 +13,7 @@ */ var _ = require('lodash'); +var path = require('path'); var sass = require('node-sass'); var nconf = require('nconf'); var settingUtil = require('../settings/settingsUtil'); @@ -22,7 +23,7 @@ var buildsass = {}; var sassOptionsDefaults = { indentedSyntax: true, includePaths: [ - nconf.get('base_dir') + '/src/sass' + path.join(__dirname, '../../src/sass') ], outputStyle: 'compressed' }; @@ -56,6 +57,19 @@ function dynamicSass(entry, vars, success, error) { }); } +function save(result) { + var fs = require('fs'); + var themeCss = path.join(__dirname, '../../public/css/app.min.css'); + fs.writeFileSync(themeCss, result); +} + +buildsass.buildDefault = function(callback) { + dynamicSass('app.sass', {}, function(result) { + save(result); + return callback(); + }, callback); +}; + buildsass.build = function(callback) { settingUtil.getSettings(function(err, s) { if (!err && s) { @@ -69,13 +83,16 @@ buildsass.build = function(callback) { tertiary: settings.colorTertiary.value, quaternary: settings.colorQuaternary.value }, function(result) { - var fs = require('fs'); - var themeCss = nconf.get('base_dir') + '/public/css/app.min.css'; - fs.writeFileSync(themeCss, result); + save(result); + return callback(); + }, callback); + } else { + // Build Defaults + dynamicSass('app.sass', {}, function(result) { + save(result); return callback(); }, callback); - } else - return callback(); + } }); }; diff --git a/src/webserver.js b/src/webserver.js index eb15c0f2a..e7aaf203c 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -122,13 +122,19 @@ var async = require('async'), require('socket.io')(server); - if (!server.listening) { - server.listen(port, '0.0.0.0', function() { + require('./sass/buildsass').buildDefault(function(err) { + if (err) { + winston.error(err); + return callback(err); + } + + if (!server.listening) { + server.listen(port, '0.0.0.0', function() { + return callback(); + }); + } else return callback(); - }); - } else - return callback(); - + }); }; })(WebServer); \ No newline at end of file