Total Complexity | 6 |
Complexity/F | 3 |
Lines of Code | 38 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
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') |
||
|
|||
34 | } |
||
35 | } |
||
36 | } |
||
37 | |||
38 | export default abeProcess |