Completed
Push — master ( 430c18...52d1c6 )
by
unknown
54s
created

src/cli/cms/data/metas.js   A

Complexity

Total Complexity 8
Complexity/F 4

Size

Lines of Code 40
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

2 Functions

Rating   Name   Duplication   Size   Complexity  
B metas.js ➔ add 0 22 6
A metas.js ➔ create 0 11 2
1
import {
2
  cmsData
3
  ,config
4
} from '../../'
5
6
export function add(json, type, date = null) {
7
  let meta = config.meta.name
8
  var currentDate = (date != null && date !== '') ? date : new Date()
9
  var abeUrl = (type === 'publish') ? json[meta].link : cmsData.fileAttr.add(json[meta].link, 'd' + cmsData.revision.removeStatusAndDateFromFileName(currentDate.toISOString())) + ''
10
11
  if(json[meta].date == null) {
12
    json[meta].date = currentDate
13
  }
14
  json[meta].latest = {
15
    date: currentDate,
16
    abeUrl: abeUrl
17
  }
18
  json[meta].status = type
19
  if(json[meta][type] == null) {
20
    json[meta][type] = {latest: {}}
21
    json[meta][type].date = currentDate
22
    json[meta][type].abeUrl = abeUrl
23
  }
24
  // json[meta][type].latest = JSON.parse(JSON.stringify(obj))
25
  json[meta][type].latest.date = currentDate
26
  json[meta][type].latest.abeUrl = abeUrl
27
}
28
29
30
export function create(json, template, url) {
31
  let meta = config.meta.name
32
  if (json[meta] == null) {
33
    json[meta] = {}
34
  }
35
36
  json[meta].template = template
37
  json[meta].link = url
38
39
  return json
40
}
41