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