Completed
Push — master ( 652c21...99e276 )
by greg
10:52 queued 08:59
created

src/cli/extend/abe-process.js   A

Complexity

Total Complexity 6
Complexity/F 3

Size

Lines of Code 38
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
nc 1
dl 0
loc 38
cc 0
rs 10
noi 1
wmc 6
mnd 3
bc 8
fnc 2
bpm 4
cpm 3

2 Functions

Rating   Name   Duplication   Size   Complexity  
A abe-process.js ➔ prepend 0 5 1
B abe-process.js ➔ abeProcess 0 22 5
1
import process from 'child_process'
2
import fse from 'fs-extra'
3
4
import {
5
  config
6
  ,Plugins
7
} from '../'
8
9
function prepend(value, array) {
10
  var newArray = array.slice(0)
11
  newArray.unshift(value)
12
  return newArray
13
}
14
15
var abeProcess = function(name, args = []) {
16
  args = prepend(`ABE_WEBSITE=${config.root}`, args)
17
  args = prepend(`ABEJS_PATH=${__dirname}/../../../dist`, args)
18
19
  var file = `${__dirname}/../../cli/process/${name}.js`
20
  try {
21
    var stats = fse.statSync(file)
22
    if (stats.isFile()) {
23
      process.fork(file, args)
24
    }
25
  }catch(err) {
26
    try {
27
      file = Plugins.instance.getProcess(name)
28
      stats = fse.statSync(file)
29
      if (stats.isFile()) {
30
        process.fork(file, args)
31
      }
32
    }catch(err) {
33
      console.log('process fork failed')
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
34
    }
35
  }
36
}
37
38
export default abeProcess