* Helper function that adds tutorial configuration to the `conf` variable. This helps when multiple * tutorial configurations are specified in one object, or when a tutorial's children are specified * as tutorial configurations as opposed to an array of tutorial names. * * Recurses as necessary
(name, meta)
| 46 | * child tutorials. |
| 47 | */ |
| 48 | function addTutorialConf(name, meta) { |
| 49 | let names; |
| 50 | |
| 51 | if (isTutorialJSON(meta)) { |
| 52 | // if the children are themselves tutorial defintions as opposed to an |
| 53 | // array of strings, add each child. |
| 54 | if (hasOwnProp.call(meta, 'children') && !Array.isArray(meta.children)) { |
| 55 | names = Object.keys(meta.children); |
| 56 | for (let childName of names) { |
| 57 | addTutorialConf(childName, meta.children[childName]); |
| 58 | } |
| 59 | // replace with an array of names. |
| 60 | meta.children = names; |
| 61 | } |
| 62 | // check if the tutorial has already been defined... |
| 63 | if (hasOwnProp.call(conf, name)) { |
| 64 | logger.warn(`Metadata for the tutorial ${name} is defined more than once. Only the first definition will be used.`); |
| 65 | } else { |
| 66 | conf[name] = meta; |
| 67 | } |
| 68 | } else { |
| 69 | // keys are tutorial names, values are `Tutorial` instances |
| 70 | names = Object.keys(meta); |
| 71 | for (let tutorialName of names) { |
| 72 | addTutorialConf(tutorialName, meta[tutorialName]); |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Add a tutorial. |
no test coverage detected
searching dependent graphs…