From 3ae042c9d706ca1c1357d82b60d071458b362b77 Mon Sep 17 00:00:00 2001 From: Thomas Taylor Date: Wed, 30 Sep 2015 20:10:10 +0100 Subject: [PATCH] Update adapt output plugin for sourcemapping --- plugins/output/adapt/index.js | 67 +++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/plugins/output/adapt/index.js b/plugins/output/adapt/index.js index 3e4c0d1b1d..f41a3547fa 100644 --- a/plugins/output/adapt/index.js +++ b/plugins/output/adapt/index.js @@ -162,34 +162,49 @@ AdaptOutput.prototype.publish = function (courseId, isPreview, request, response logger.log('info', '3.2. Using theme: ' + themeName); logger.log('info', '3.3. Using menu: ' + menuName); - var isProduction = configuration.conf.isProduction; - var buildMode = isProduction ? 'prod' : 'dev'; - - logger.log('info', 'grunt server-build:' + buildMode + ' ' + args.join(' ')); - - child = exec('grunt server-build:' + buildMode + ' ' + args.join(' '), {cwd: path.join(FRAMEWORK_ROOT_FOLDER)}, - function (error, stdout, stderr) { - if (error !== null) { - logger.log('error', 'exec error: ' + error); - logger.log('error', 'stdout error: ' + stdout); - resultObject.success = true; - return callback(error, 'Error building framework'); + database.getDatabase(function (error, db) { + if (error) { + return next(error); } - if (stdout.length != 0) { - logger.log('info', 'stdout: ' + stdout); - resultObject.success = true; - return callback(null, 'Framework built OK'); - } - - if (stderr.length != 0) { - logger.log('error', 'stderr: ' + stderr); - resultObject.success = false; - return callback(stderr, 'Error (stderr) building framework!'); - } - - resultObject.success = true; - return callback(null, 'Framework built'); + db.retrieve('config', { _courseId: courseId }, function (error, matches) { + if (error) { + return next(error); + } + + if (matches && matches[0]) { + var generateSourcemap = matches[0]._doc._generateSourcemap; + } + + var buildMode = generateSourcemap === true ? 'dev' : 'prod'; + + logger.log('info', 'grunt server-build:' + buildMode + ' ' + args.join(' ')); + + child = exec('grunt server-build:' + buildMode + ' ' + args.join(' '), {cwd: path.join(FRAMEWORK_ROOT_FOLDER)}, + function (error, stdout, stderr) { + if (error !== null) { + logger.log('error', 'exec error: ' + error); + logger.log('error', 'stdout error: ' + stdout); + resultObject.success = true; + return callback(error, 'Error building framework'); + } + + if (stdout.length != 0) { + logger.log('info', 'stdout: ' + stdout); + resultObject.success = true; + return callback(null, 'Framework built OK'); + } + + if (stderr.length != 0) { + logger.log('error', 'stderr: ' + stderr); + resultObject.success = false; + return callback(stderr, 'Error (stderr) building framework!'); + } + + resultObject.success = true; + return callback(null, 'Framework built'); + }); + }); }); } else { resultObject.success = true;