Skip to content

Commit

Permalink
Add a loadLanguages() function for easy component loading on NodeJS (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Mar 20, 2018
1 parent a52319a commit a5331a6
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var components = require('../components.js');

function loadLanguages(arr) {
// If no argument is passed, load all components
if (!arr) {
arr = Object.keys(components.languages).filter(function (lang) {
return lang !== 'meta';
});
}

if (!Array.isArray(arr)) {
arr = [arr];
}
arr.forEach(function(language) {
// Load dependencies first
if (components.languages[language] && components.languages[language].require) {
loadLanguages(components.languages[language].require);
}

require('./prism-' + language);
});
}

module.exports = loadLanguages;

0 comments on commit a5331a6

Please sign in to comment.