| Total Complexity | 9 |
| Complexity/F | 1.8 |
| Lines of Code | 34 |
| Function Count | 5 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | import path from 'path' |
||
| 2 | import mkdirp from 'mkdirp' |
||
| 3 | import execPromise from 'child-process-promise' |
||
| 4 | |||
| 5 | import { |
||
| 6 | coreUtils, |
||
|
|
|||
| 7 | cmsStructure, |
||
| 8 | cmsData, |
||
| 9 | config |
||
| 10 | } from '../../' |
||
| 11 | |||
| 12 | export function addFolder(folderPath) { |
||
| 13 | mkdirp(path.join(config.root, folderPath), function (err) { |
||
| 14 | if (err) console.error(err) |
||
| 15 | }) |
||
| 16 | return folderPath |
||
| 17 | } |
||
| 18 | |||
| 19 | export function removeFolder(folderPath) { |
||
| 20 | execPromise.exec('rm -rf ' + path.join(config.root, folderPath)).then(function (result) { |
||
| 21 | var stdout = result.stdout |
||
| 22 | var stderr = result.stderr |
||
| 23 | if(stdout) console.log('stdout: ', stdout) |
||
| 24 | if(stderr) console.log('stderr: ', stderr) |
||
| 25 | }) |
||
| 26 | return folderPath |
||
| 27 | } |
||
| 28 | |||
| 29 | export function editStructure(type, folderPath) { |
||
| 30 | if(type === 'add') cmsStructure.structure.addFolder(folderPath) |
||
| 31 | else cmsStructure.structure.removeFolder(folderPath) |
||
| 32 | |||
| 33 | return folderPath |
||
| 34 | } |
||
| 35 |