Skip to content

Commit

Permalink
Update adapt output plugin for sourcemapping
Browse files Browse the repository at this point in the history
  • Loading branch information
taylortom committed Sep 30, 2015
1 parent fc3c5d8 commit 3ae042c
Showing 1 changed file with 41 additions and 26 deletions.
67 changes: 41 additions & 26 deletions plugins/output/adapt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

This comment has been minimized.

Copy link
@brian-learningpool

brian-learningpool Nov 11, 2015

Member

The outputJson object already contains the config for this course. You don't need to retrieve it again here.

This comment has been minimized.

Copy link
@taylortom

taylortom Nov 11, 2015

Author Member

Ok great, will update that.

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;
Expand Down

0 comments on commit 3ae042c

Please sign in to comment.