Completed
Push — master ( c8cc0a...f17656 )
by Thomas
44s
created

lib/containers/Module.js   A

Complexity

Total Complexity 7
Complexity/F 3.5

Size

Lines of Code 27
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
wmc 7
c 1
b 0
f 0
nc 4
mnd 1
bc 4
fnc 2
dl 0
loc 27
rs 10
bpm 2
cpm 3.5
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A Module.getManifest 0 14 1
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