| Total Complexity | 7 |
| Complexity/F | 3.5 |
| Lines of Code | 27 |
| Function Count | 2 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | 'use strict' |
||
| 2 | |||
| 3 | const jsonfile = require('jsonfile') |
||
| 4 | const output = require('../output') |
||
| 5 | |||
| 6 | var Module = {} |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Get the manifest object for the module in the current directory. |
||
| 10 | * @param {function(ModuleManifest)} callback |
||
| 11 | */ |
||
| 12 | Module.getManifest = function (callback) { |
||
| 13 | jsonfile.readFile('module.json', function (err, module) { |
||
| 14 | if (err) { |
||
| 15 | output.err('Error reading module.json: ' + err) |
||
| 16 | return |
||
| 17 | } |
||
| 18 | if (!('slug' in module) || !module.slug || typeof module.slug !== 'string' || !module.slug.length) { |
||
| 19 | output.err('Please set a valid value for module.slug') |
||
| 20 | return |
||
| 21 | } |
||
| 22 | |||
| 23 | callback(module) |
||
| 24 | }) |
||
| 25 | } |
||
| 26 | |||
| 27 | module.exports = Module |
||
| 28 |