lib/commands/plugins/install.js   A
last analyzed

Complexity

Total Complexity 5
Complexity/F 2.5

Size

Lines of Code 37
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
wmc 5
c 1
b 0
f 0
nc 1
mnd 1
bc 5
fnc 2
dl 0
loc 37
rs 10
bpm 2.5
cpm 2.5
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
B module.exports 0 32 3
1
const install = require('spawn-npm-install')
2
const Plugins = require('../../util/Plugins')
3
const output = require('../../output')
4
const fs = require('fs')
5
6
module.exports = function (name) {
7
  if (name.indexOf('cli-') < 0) {
8
    name = '@includable/cli-' + name
9
  }
10
11
  if (!fs.existsSync(Plugins.packageFile)) {
12
    const json = {
13
      'private': true,
14
      'name': 'my-inc-plugins',
15
      'description': 'Auto-generated by the Includable CLI!',
16
      'version': '0.0.1',
17
      'license': 'MIT',
18
      'dependencies': {}
19
    }
20
    fs.writeFileSync(Plugins.packageFile, JSON.stringify(json, null, 3), 'utf8')
21
  }
22
23
  install(name, {
24
    cwd: Plugins.directory,
25
    noShrinkwrap: true,
26
    production: true,
27
    noBinLinks: true,
28
    save: true
29
  }, function (err) {
30
    if (err) {
31
      output.errSimple(err.message)
32
      return
33
    }
34
35
    Plugins.describePlugin(name)
36
  })
37
}
38