Total Complexity | 8 |
Complexity/F | 4 |
Lines of Code | 31 |
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 | const createManifest = require('./ModuleManifest') |
||
7 | |||
8 | var Module = {} |
||
9 | |||
10 | /** |
||
11 | * Get the manifest object for the module in the current directory. |
||
12 | * @param {function(ModuleManifest)} callback |
||
13 | * @param {string} basePath |
||
14 | */ |
||
15 | Module.getManifest = function (callback, basePath) { |
||
16 | var modulePath = basePath ? path.join(basePath, 'module.json') : 'module.json' |
||
17 | jsonfile.readFile(modulePath, function (err, module) { |
||
18 | if (err) { |
||
19 | output.err('Error reading module.json: ' + err) |
||
20 | return |
||
21 | } |
||
22 | if (!('slug' in module) || !module.slug || typeof module.slug !== 'string' || !module.slug.length) { |
||
23 | output.err('Please set a valid value for module.slug') |
||
24 | return |
||
25 | } |
||
26 | |||
27 | callback(createManifest(module)) |
||
28 | }) |
||
29 | } |
||
30 | |||
31 | module.exports = Module |
||
32 |