• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

scriptype / writ-cms / 19380040712

14 Nov 2025 11:05PM UTC coverage: 19.229% (-0.09%) from 19.323%
19380040712

push

github

scriptype
Modernize models/collection for post and attachment use

Also when a data file is detected, try to parse '[]' if the file is
empty. Otherwise, boom.

Why tolerate empty data file? It happens when you create it by hand.
Watch mode goes blue screen as soon as you create the data file, not
good.

147 of 3429 branches covered (4.29%)

Branch coverage included in aggregate %.

1 of 13 new or added lines in 1 file covered. (7.69%)

120 existing lines in 5 files now uncovered.

920 of 2120 relevant lines covered (43.4%)

100.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

67.44
/src/lib/parseTextEntry.js
1
const _ = require('lodash')
9✔
2
const frontMatter = require('front-matter')
9✔
3
const slug = require('slug')
9✔
4
const { removeExtension, Markdown } = require('./contentModelHelpers')
9✔
5

6
const parseContent = (node, content) => {
9✔
7
  if (node.extension.match(/(html|htm|hbs|handlebars)/i)) {
144!
8
    return content
×
9
  }
10
  return Markdown.parse(content)
144✔
11
}
12

13
const normalizeEntryName = (fsNode, indexNode) => {
9✔
14
  const hasIndex = fsNode !== indexNode
144✔
15
  const entryName = hasIndex ? fsNode.name : removeExtension(indexNode.name)
144!
16
  return {
144✔
17
    hasIndex,
18
    entryName
19
  }
20
}
21

22
const parseFlatData = (data) => {
9✔
UNCOV
23
  const contentRaw = data.content || ''
×
UNCOV
24
  const content = Markdown.parse(contentRaw)
×
25

UNCOV
26
  return {
×
27
    ...data,
28
    hasIndex: false,
29
    title: data.title || '',
×
30
    slug: data.slug || slug(data.title),
×
31
    contentRaw,
32
    content
33
  }
34
}
35

36
const parseTextEntry = (fsNode, indexNode, isFlatData) => {
9✔
37
  if (isFlatData) {
144!
UNCOV
38
    return parseFlatData(fsNode)
×
39
  }
40
  const { attributes, body } = frontMatter(indexNode.content)
144✔
41
  const { hasIndex, entryName } = normalizeEntryName(fsNode, indexNode)
144✔
42
  const contentRaw = body || ''
144✔
43
  const content = parseContent(indexNode, contentRaw)
144✔
44

45
  return {
144✔
46
    ..._.omit(fsNode, 'children'),
47
    ...attributes,
48
    hasIndex,
49
    title: attributes.title || entryName,
288✔
50
    slug: attributes.slug || slug(entryName),
288✔
51
    contentRaw,
52
    content
53
  }
54
}
55

56
module.exports = {
9✔
57
  parseContent,
58
  normalizeEntryName,
59
  parseFlatData,
60
  parseTextEntry
61
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc