Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions grunt/tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = function(grunt) {
grunt.registerTask('build', 'Creates a production-ready build of the course', [
'_log-vars',
'check-json',
'check-plugins',
'clean:output',
'build-config',
'tracking-insert',
Expand Down
1 change: 1 addition & 0 deletions grunt/tasks/check-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = function(grunt) {
grunt.registerTask('check-json', 'Validates the course json, checks for duplicate IDs, and that each element has a parent', function() {
// validates JSON files
grunt.task.run('jsonlint');
grunt.task.run('check-plugins');
const data = Helpers.getFramework().getData();
data.checkIds();
});
Expand Down
27 changes: 27 additions & 0 deletions grunt/tasks/check-plugins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = function(grunt) {
const Helpers = require('../helpers')(grunt);
grunt.registerTask('check-plugins', 'Checks that only one theme is active in the build', function() {
// A specific theme was selected via CLI flag (e.g. --theme=X),
// so only that one will be compiled regardless of what's installed
if (grunt.config('theme') !== '**') return;

const includes = grunt.config('includes');
const excludes = [
...(grunt.config('excludes') || []),
...(grunt.config('type') === 'production' ? (grunt.config('productionExcludes') || []) : [])
];

const installed = Helpers.getInstalledPluginsByType('theme');
const active = includes
? installed.filter(name => includes.includes(name))
: installed.filter(name => !excludes.includes(name));

if (active.length <= 1) return;

grunt.fail.fatal(
`More than one theme is active in this build: ${active.join(', ')}.\n` +
`Add the extras to build.excludes in config.json, e.g.:\n` +
` "build": { "excludes": ["${active.slice(1).join('", "')}"] }`
);
});
};
1 change: 1 addition & 0 deletions grunt/tasks/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = function(grunt) {
grunt.registerTask('dev', 'Creates a developer-friendly build of the course', [
'_log-vars',
'check-json',
'check-plugins',
'build-config',
'tracking-insert',
'copy',
Expand Down
Loading