Completed
Push — master ( 78b7d3...971ae6 )
by Thomas
49s queued 29s
created

module.exports   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
c 1
b 0
f 0
nc 4
dl 0
loc 32
rs 8.8571
nop 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A 0 8 2
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